Chaitanya Kumar Ch
Chaitanya Kumar Ch

Reputation: 309

Search through child records fields of given parent using hibernate lucene search

I have two tables for example Books, Author. Every book reord is referenced by author id. I would like to search books which matches given keyword but specific to given author. How to achieve this using hibernate lucene search? Do I need to use filters?

Upvotes: 0

Views: 333

Answers (2)

Chaitanya Kumar Ch
Chaitanya Kumar Ch

Reputation: 309

Alternative for KeywordTokenizer is @Field(analyze = Analyze.NO). It also matches exact value.

Upvotes: 0

Guillaume Smet
Guillaume Smet

Reputation: 10529

Please read the Hibernate Search documentation: you have an example with exactly that in the first section of the documentation.

Start at https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#_configuration . You'll have every steps explained in the following paragraphs.

You can use the Hibernate Search DSL to build your query easily by first matching your keyword on the book fields, then matching the author using the author.id field.

Upvotes: 1

Related Questions