creating a lucene index to find parent based on data of children

172 Views Asked by At

I am trying to understand how to build a lucene index for data that has a 1 to many relation.

suppose I have a table for families with id and family name and a table of people with id, first name, and hobbies (which is free text).

how would I create a lucene index that will help me find families that have family members that their hobbies match the search query (as full text search) ?

I want to get each matching family just once (even if there are several family members that their hobbies are a hit for the query.

What If I also had a hobbies field on the family record it self (in addition to personal hobbies) and I wanted to get all the families that either match on the family hobby or on the hobby of on of the family members ?

1

There are 1 best solutions below

1
On BEST ANSWER

You may treat families as documents that are composed of hobbies (terms). Index hobbies in a searchable field, no matter they are family hobbies or personal hobbies. For the rest of the fields just store them as additional fields.