We need to create a search which from this filter:
hair must equal BLOND
will only return matching children, or parents who match, and do not have matching children
[
// this is a matching child, so its parent (_id:1) will not be returned
{
returned
_id: "2"
name: "007",
hair: "BLOND",
actual_id: "1" // this is a the parent marker in our data
},
// this parent has no matching children, AND hair is blond, so it will be returned
{
_id: "3"
name: "Jane Doe",
hair: "BLOND",
actual_id: "3"
}
// babe ruth (_id:4) has BROWN hair so he is NOT returned
]
Can this be accomplished with the parent/child relationship in ES or should we plan additional data juggling on our side?
Do you think my scenario would be easier with 2 indexs? One of children and one of parents. Then:
first do a query on children index
then do a query on parent index, removing any of the actual_id's from the first call?
This setup would get dicey if for instance the user is looking for results 51-to-100. This would get very hard, and I would pretty much need to request children 1 to 100, and calculate the first 50 items, even though they are not needed.
The trick I need is, if a child matches a query then its matching parent is not returned. But other matching parents without matching children DO need to be returned.
Thanks for bearing with me. I tried to make simpler data than our real use-case.
We have an accounting software. There are official names for products such as "Verizon E-Line 1000". Customers however, may refer to that service by different names internally "VZN E1000" "Verizon Business ELine"... etc and our system is good at matching the customer preferred name to the product's official name.
When the customer does a search on their products which can be done by a variety of filters or query methods they need to see their preferred name "VZN E1000" instead of the official name.
So to convert my first example:
James Bond = official name: Verizon E-Line 1000
007 = client's preferred name: VZN E1000
BLOND = client's name "ABC INC"
As for additional fields to search on, we need a text search on name, and about 3-4 facet categories for this type of search.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.