Hello,
I'm looking for a solution to a problem I am having. Lets say I have 2
types Person and Pet in an index called customers.
Person
-account
-firstname
-lastname
-SSN
Pet
-name
-type
-id
-account
I would like to query/filter on fields in both person and pet in order to
retrieve people and their associated pet. Additionally, I need to sort on
a field that could be in either person or pet.
For example, retrieve all people/pets that have wildcard person.firstname
'ave' and pet.type wildcard 'terrier' and sort on pet.name. Or
wildcard search on person.SSN = '55' and pet.name='mister' and sort on
person.lastname.
I currently have a solution where I search/sort on people or pet based on
the sort that I am using. I use a hasChild/hasParent to manage the fields
that are on the 'other' type. Then I use an id field to retrieve the
entities of the other type. So, if I have a sort on personfirstname, I
query on person and child (pet) and sort on person.firstname, then use the
accounts to retrieve the pets (by account) in another query. This is not
ideal because it is ugly and I suspect difficult to maintain if this
query's requirements change in the future.
I suspect that I can do a query at the 'customers' level and do 'type'
queries on the fields that I need for person and pet. Similar to this:
http://joelabrahamsson.com/grouping-in-elasticsearch-using-child-documents/
However, I'm not sure how I would implement the sort. I suspect that I
could use a custom scoring script, but I am not sure how I would score text
fields.
Any thoughts?
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/53e9d304-d1e3-4994-b95f-3e5f0052ec96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.