I need to perform a series of complex calculations to perform document matching.
After many attempts, I have seen that the best way was to work with Painless since I have to combine many types of document, some of type keyword (actually they are enum fields, which I have treated as keywords)
My first test worked. At least, he did what he wanted, multiply the value of the score received by 2 if the type interest had the value 'any'
GET /excellenting/proposals/_search
{
"explain": true,
"from": 0,
"size": 10,
"query": {
"function_score": {
"query": {
"bool" : {
"should": [
{
"match": {
"title": "Virtual Reality office recreation"
}
},
{
"match": {
"abstract": "Virtual Reality office recreation"
}
}
]
}
},
"script_score": {
"script": "int p_interest = 0; int p_category = 0; p_interest = (doc['interest'].value == 'any' ? 2 : 1); p_category = ((doc['tech_category'].value >= 90800 || doc['tech_category'].value <= 90899) ? 2 : 1); return _score * (p_interest + p_category)"
},
"score_mode": "multiply"
}
}
}
Now my problem is that I do not know if I can pass values to the script when I send the POST (search) to ES.
I try to explain myself better.
I have to add another calculation that depends on the value that is passed in the query.
That is to say,
The value 90899 and 90800 need to be sent in the POST of the search, and I can not find the way to do it,
Best regards