I am using Hibernate Search and applied Lucene indexing on one table for a domain object. I want now to make selection from this table for domain objects and apply filtering based on joining with other table, which is not indexed.
For exampple, I have Auction Lots table, which I have indexed. And I have Quotes table. Quotes have references to Auction Lots.
I want to conduct full test search in AuctionLots table and return matched entities which have no quotes. In ordinary SQL this would achieved by JOIN.
But in the situation with HibernateSearch, I have to make full test search in order to obtain domain objects, but I don’t know how to perform filtering with JOIN.
Does any body have an idea how to do this?
I don’t recommend filtering when creating the indexes for your search. Mainly because it is not supported by Hibernate Search as far as I know, but also because it makes no sense. What you should do in my opinion, is index the object you want to search for, including the relations to the ‘child’ objects.
I assume your ActionLot object has a one-to-many relation to your Quotes objects. With the
@IndexEmbeddedannotation, you can mark your Quotes as objects which should be indexed as well.When you search for the ActionLots without quotes, you can filter this during your search using either restrictions in your search query, or by applying a global filter to your search. This can be done using the filter options provided by Hibernate Search.