I have a index that looks like this stripped down example:
{
"elastic-demo": {
"mappings": {
"demo_index": {
"properties": {
"id": {
"type": "text",
"index": false
},
"score": {
"type": "long"
},
"tags": {
"type": "nested",
"properties": {
"label": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"my_boost": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"tag": {
"properties": {
"label": {
"type": "keyword"
},
"my_boost": {
"type": "double"
}
}
}
}
}
}
}
}
}
}
and I would like to search for a tag "test" and have the tag that matches the search's my_boost
be multiplied by the main doc's score
.
So for example,
I search for "test"
{
"from":0,
"size": 5,
"query": {
"nested": {
"path": "tags",
"score_mode": "avg",
"query": {
"bool": {
"must": [{
"match": {
"tags.label": "test"
}
}]
}
}
}
}
}
and I get results
{
"took": 2,
"timed_out": false,
"hits": {
"total": 1,
"max_score": 7.690165,
"hits": [
{
"_index": "demo_indices",
"_type": "demo_index",
"_id": "abcd",
"_score": 7.690165,
"tags": [
{
"label": "test",
"my_boost": 6,
"approved_by_owner": false
}
],
"score": 100
}
]
}
}
I actually want the score to be score
* boost * _score
; so 100 * 6 * 7.690165 = 4614
Does that make sense? Can it be done? I feel like https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-field-value-factor is what I am looking for, but I can't figure out how to get the specific nested tag
Thanks in advance