I am trying to formulate a Elastic Search query using field_value_factor to weigh some fields in the documents.
{
"query": {
"match": {
"local": true
},
"function_score": {
"functions": [
{
"field_value_factor": {
"field": "title",
"factor": 1.2,
"missing": 1
}
},
{
"gauss": {
"location": {
"origin": {
"lat": 51.5,
"lon": 0.12
},
"offset": "2 Miles",
"scale": "3 Miles"
}
}
},
{
"gauss": {
"creation_time": {
"decay": 0.8,
"offset": "2d",
"scale": "48d"
}
},
"weight": 2
}
]
}
}
}
Any input like:
"field_value_factor": {
"field": [“title”,"description"],
"factor": [1.2,0.8],
"missing": [1,0]
}
does not work for both the fields and the query retrieves same documents as the first one.
Is it possible to input multiple terms in the "field_value_vector" ?
You can use several field_value_factor
functions, one for each field
{
"query": {
"match": {
"local": true
},
"function_score": {
"functions": [
{
"field_value_factor": {
"field": "title",
"factor": 1.2,
"missing": 1
}
},
{
"field_value_factor": {
"field": "description",
"factor": 0.8,
"missing": 0
}
},
{
"gauss": {
"location": {
"origin": {
"lat": 51.5,
"lon": 0.12
},
"offset": "2 Miles",
"scale": "3 Miles"
}
}
},
{
"gauss": {
"creation_time": {
"decay": 0.8,
"offset": "2d",
"scale": "48d"
}
},
"weight": 2
}
]
}
}
}