Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;

   ...
}
like image 535
sudhir Avatar asked Jan 29 '26 09:01

sudhir


1 Answers

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.

like image 164
Hardy Avatar answered Jan 30 '26 22:01

Hardy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!