Add more than one custom script in function_score


(@mromagnoli) #1

My doubt is about putting more than one custom script in my funtion score.
Is that possible?

I have something like this:

POST /lz/listing/_search?pretty=true
{
"from": 1,
"size": 20,
"query": {
"function_score": {
"query": {
"bool": {
"should": [{
"multi_match": {
"query": "pizza",
"fields": ["Listing.name.standard^10"],
"use_dis_max": false
}
}],
"must": {
"terms": {
"Zone.id": ["1"]
}
},
"minimum_should_match": 1
}
},
"script_score": {
"params": {
"times": 10,
"default": 0.1
},
"script": ["doc['Review.id'].empty ? _score * default :
_score * doc['Review.id'].values.length * times"]
}
}
},
"sort": ["_score"],
"track_scores": true
}

Is there any way to indicate that the score has to take in account de
script set in 'script_score' and another one like in an "or"|"and" filter
or something like that?

I think like this:

"script_score": {
"params": {
"times": 10,
"default": 0.1
},
"script": [
"doc['Review.id'].empty ? _score * default : _score

  • doc['Review.id'].values.length * times",
    "doc['Bookmark.id'].empty ? _score * default :
    _score * doc['Bookmark.id'].values.length * times"
    ]
    }

Hope I was clear :wink:

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #2