Hi, guys.
I want to sum score in multi match query with cross_field type and set tie_breaker to 1.0. I test two versions of Elasticsearch: 5.4.0 and 6.2.1. Version 5.4.0 works as expected, but in 6.2.1 occurs maximum instead of summary, as I wanted.
Example code:
PUT test { "settings": { "number_of_replicas": 0, "number_of_shards": 1 }, "mappings": { "type1": { "properties": { "title": { "type": "text" }, "description": { "type": "text" } } } } }
POST test/type1 { "title": "Great Gatsby", "description": "Great Gatsby is the book about ..." } GET test/type1/_search { "explain": true, "query": { "multi_match": { "query": " Great Gatsby", "type": "cross_fields", "tie_breaker": 1, "fields": ["title^0.9", "description^0.4"] } } }
Result in 5.4.0:
{ "took": 3, "timed_out": false, "_shards": { "total": 1, "successful": 1, "failed": 0 }, "hits": { "total": 1, "max_score": 0.67854714, "hits": [ { "_shard": "[test][0]", "_node": "6I5w97MhSqiV-kkuiKq3Ig", "_index": "test", "_type": "type1", "_id": "AWH2m1UNIkD_TjFR4SoN", "_score": 0.67854714, "_source": { "title": "Great Gatsby", "description": "Great Gatsby is the book about ..." }, "_explanation": { "value": 0.67854714, "description": "sum of:", "details": [ { "value": 0.33927357, "description": "**sum of**:", "details": [ { "value": 0.10696911, "description": "weight(description:great in 0) [PerFieldSimilarity], result of:", "details": ... }, { "value": 0.23230445, "description": "weight(title:great in 0) [PerFieldSimilarity], result of:", "details": ... } ] }, { "value": 0.33927357, "description": "**sum of**:", "details": [ { "value": 0.10696911, "description": "weight(description:gatsby in 0) [PerFieldSimilarity], result of:", "details": ... }, { "value": 0.23230445, "description": "weight(title:gatsby in 0) [PerFieldSimilarity], result of:", "details": ... ] } ] } ] } } ] } }
Result in 6.2.1:
{ "took": 0, "timed_out": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": 1, "max_score": 0.51782775, "hits": [ { "_shard": "[test][0]", "_node": "fUje_eDeTp6kXL83BFQM_Q", "_index": "test", "_type": "type1", "_id": "LF6d9mEBXfZ7hY5VVfJU", "_score": 0.51782775, "_source": { "title": "Great Gatsby", "description": "Great Gatsby is the book about ..." }, "_explanation": { "value": 0.51782775, "description": "sum of:", "details": [ { "value": 0.25891387, "description": "**max of**:", "details": [ { "value": 0.25891387, "description": "weight(title:great in 0) [PerFieldSimilarity], result of:", "details": [ { "value": 0.25891387, "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:", "details": ... } ] }, { "value": 0.11507284, "description": "weight(description:great in 0) [PerFieldSimilarity], result of:", "details": ... } ] }, { "value": 0.25891387, "description": "**max of**:", "details": [ { "value": 0.25891387, "description": "weight(title:gatsby in 0) [PerFieldSimilarity], result of:", "details": ... }, { "value": 0.11507284, "description": "weight(description:gatsby in 0) [PerFieldSimilarity], result of:", "details": ... } ] } ] } } ] } }