Hi all, I have a set of extracted terms, with associated relevancy scores and other metadata, from each document. I'd like to scale _score by the relevancy of the matched terms. It seems to me there are at least two approaches for solving this problem:
1) Nested Document: In this case, my mapping would look like: { "contentDocument": { "properties": { "content": { "type": "string" }, "terms": { "type": "nested", "fields": { "text": { "type": "string", }, "relevance": { "type": "float" } } } } } } Then I could query using: { "query": { "nested": { "score_mode": "max", "path": "terms", "query": { "function_score": { "boost_mode": "replace", "score_mode": "multiply", "query": { "match": { "terms.text": "<my text>" } }, "functions": [ { "field_value_factor": { "field": "terms.relevance" } } ] } } } } } This seems to work as expected on the small prototype I've built. 2. Parent/Child Documents: In this case, my mapping would look like: { "contentDocument": { "properties": { "content": { "type": "string" } } } } { "termDocument": { "_parent": { "type": "contentDocument" }, "properties": { "text": { "type": "string" }, "relevance": { "type": "float" } } } } Then I could query using: { "query": { "has_child": { "type": "termDocument", "score_mode": "max", "query": { "function_score": { "boost_mode": "replace", "score_mode": "multiply", "query": { "match": { "text": "<my text>" } }, "functions": [ { "field_value_factor": { "field": "termDocument.relevance" } } ] } } } } } This also seems to work in the prototype. So, both options seem to work, which is great! However, I'm not sure if there are any performance (or other) concerns with approaches? We will have millions of documents (and associated terms), so we need our solution to scale well. It seems to me that the nested approach is conceptually more straightforward, so I'm leaning in that directly, but wanted to get input for larger ES community. Please let me know if there is any other options that might work better! I've also considered using payloads: https://groups.google.com/forum/#!searchin/elasticsearch/Scott$20Decker%7Csort:date/elasticsearch/gEcBVhSynnY/4N1XD5NyseMJ However, I'm not sure that will work for us as there is metadata, other than relevancy, I'd like to store about each term. Thank you! -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/92296554-97e0-4755-a648-72224c58fea4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.