elasticsearch - Elastic Search nested multimatch query -
so problem same described here, still remains unanswered on group.
my mapping:
{ "abstract": { "properties": { "summary": { "type": "string" } } }, "authors": { "type": "nested", "properties": { "first_name": { "type": "string" }, "last_name": { "type": "string" } } } }
and perform full-text search on both of these fields, unequally weighted. query comes mind, unfortunately doesn't work, this:
{ "query": { "bool": { "should": [{ "multi_match": { "query": "higgs boson", "fields": ["abstract.summary^5", "author.last_name^2"] } }] } } }
i don't results authors field, because of nested mapping. can't rid of nested property - use aggregations. elegant idea how solve it?
changing mapping following 1 uses include_in_root: true
allow use query original wrote:
{ "abstract": { "properties": { "summary": { "type": "string" } } }, "authors": { "type": "nested", "include_in_root": true, "properties": { "first_name": { "type": "string" }, "last_name": { "type": "string" } } } }
you may want index inner objects both nested fields , flattened object fields. can achieved setting include_in_parent true. - link
note: include_in_root
may deprecated in future versions of elasticsearch in favor of copy_to
.
Comments
Post a Comment