Hi,
does anyone have a working example for using percolate with scoring? It seems that the ones in the docs/github aren't working anymore due to dynamic scripts being disabled by default now.
I am storing queries like this under the .percolator type:
{
_id: 1,
query: {
multi_match: {
query: "some query",
operator: 'and',
fields: ['title.shingles^2', 'body.shingles'],
tie_breaker: 0.2
}
},
popularity: 4,
analyzer: 'analyzer_shingle_for_tags'
}
I want to percolate a document of this format:
{
title: "some string",
body: "some other string"
}
but I want the returned matched queries to be scored and sorted according the the popularity.
The request I am using currently is this:
{
doc: {... a document like the one above ... }
query: {
function_score: {
query: { match_all: {}},
functions: [
{
script_score: {
script: 'get_popularity'
}
}
]
}
},
sort: true,
size: 10,
track_scores: true
}
where get_popularity.groovy is in my scripts folder and has this content:
return doc['popularity'].value
But I get an error:
org.elasticsearch.ElasticsearchIllegalArgumentException: malformed sort format, either start with array, object, or an actual string