sudhir
sudhir

Reputation: 147

Projection of Collections in lucene query in hibernate search

I am trying to use @IndexEmbedded annotation for indexing. The results are correct when i check using Luke.( i am getting all the elements of List).

But when i tried to use this list in projection in Lucene Query, i am getting null.

I read somewhere that "projection does not work on collections or maps which are indexed via @IndexedEmbedded"

Is there any other way out to project this List.

  @Indexed
public class Item {

   ...

  @IndexedEmbedded
  private List<Keyword> keywords;

   ...
}

@Indexed
public class Keyword {

   ...

  @Field
  private String value;

   ...
}

Upvotes: 3

Views: 927

Answers (1)

Hardy
Hardy

Reputation: 19109

Right, as per documentation:

you can only project simple properties of the indexed entity or its embedded associations. This means you cannot project a whole embedded entity.

projection does not work on collections or maps which are indexed via @IndexedEmbedded

One could try to implement a custom two-way field bridge for keywords by encoding the order and content of the actual keywords in the document. Not sure whether it is a good idea though.

Upvotes: 3

Related Questions