質問

Here is a basic outline of my code:

@Entity
@Indexed
public class Document {

  @IndexedEmbedded
  @OneToMany(cascade = { PERSIST, MERGE }, mappedBy = "owner")
  private final Set<Issue> issues = new LinkedHashSet<Issue>();
}

@Entity
public class Issue {

  @ManyToOne
  @JoinColumn(name = "owner_id")
  @ContainedIn
  private final Document owner;

  @IndexedEmbedded
  @OneToOne(cascade = ALL, optional = false)
  @JoinColumn(name = "name_id")
  @ForeignKey(name = "FK_issue__name_id__text_element")
  private final TextElement name = new TextElement();
}

@Entity
public class TextElement {

  @OneToMany(cascade = { CascadeType.ALL })
  @JoinTable(
    name = "text_element_paragraph",
    joinColumns = { @JoinColumn(name = "text_element_id") },
    inverseJoinColumns = { @JoinColumn(name = "paragraph_id") },
    uniqueConstraints = { 
    @UniqueConstraint(
     name = "UX_text_element_paragraph__paragraph_id", 
     columnNames = "paragraph_id"        
    )
   }
  )
  @ForeignKey(
    name = "FK_text_element_paragraph__text_element_id__text_element",
    inverseName = "FK_text_element_paragraph__paragraph_id__paragraph"
  )
  @IndexedEmbedded
  private List<Paragraph> paragraphs = new LinkedList<Paragraph>();
}

@Entity
public class Paragraph {

  @Field(name = "data", analyze = Analyze.YES)
  @Column(name = "s_data", nullable = false)
  private String data;
}

I thought that lucene would be indexing the data in Paragraph, but when I open Luke it shows "issues.name.id" (id comes from a class Document extends). Why isn't the data be indexed? Thanks :)

I should also note that I just removed a manual indexer from the update method in the CRUD service. Everything stopped working after that, could it be something with my configurations?

役に立ちましたか?

解決

By adding the following to TextElement I was able to get search working:

@ContainedIn
private Document owner 

他のヒント

I think all entities have to be annotated as @Indexed, otherwise @IndexEmbedded would not recognize entities to be indexed.

By the way: deep traversing may cause problems with re-indexing. You need to go the whole way back with @ContainedIn...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top