I'm trying to apply Highlight Query and want to give more score to the number of fields highlighted by the highlight query than the term frequency on a field.
For example:
DOC 1:
{
"first_name": "John"
"last_name": "Smith"
"full_name": "John Smith"
}
DOC 2:
{
"first_name": "John"
"last_name": "Stokes"
"full_name": "John Smith John Smith"
}
When I search using the full_name field, I want DOC1 should be the first match. This is my query.
{
"query": {
"query_string": {
"query": "John Smith",
"fields": [
"full_name"
],
"use_dis_max": true,
"tie_breaker": 0,
"default_operator": "or",
"auto_generate_phrase_queries": false,
"max_determinized_states": 10000,
"enable_position_increments": true,
"fuzziness": "AUTO",
"fuzzy_prefix_length": 0,
"fuzzy_max_expansions": 50,
"phrase_slop": 0,
"escape": false,
"split_on_whitespace": true,
"boost": 1
}
},
"rescore": {
"window_size": 50,
"query": {
"score_mode": "multiply",
"rescore_query": {
"function_score": {
"script_score": {
"script": {
"source": "1"
}
}
}
},
"rescore_query_weight": 10
}
},
"highlight": {
"pre_tags": [
""
],
"post_tags": [
""
],
"highlight_query": {
"query_string": {
"query": "John Smith",
"fields": [
"full_name"
],
"use_dis_max": true,
"tie_breaker": 0,
"default_operator": "or",
"auto_generate_phrase_queries": false,
"max_determinized_states": 10000,
"enable_position_increments": true,
"fuzziness": "AUTO",
"fuzzy_prefix_length": 0,
"fuzzy_max_expansions": 50,
"phrase_slop": 0,
"escape": false,
"split_on_whitespace": true,
"boost": 1
}
},
"require_field_match": false,
"fields": {
"*": {
"fragment_size": 300,
"number_of_fragments": 1
}
}
}
}