Hello everybody,
I have been struggling all afternoon trying to combine a filter with my score function and script. I have been struggling just to implement a simple filter (I do not wish to impact the scoring function, just score the "Appartments").
I would love some outside help
Thanks a lot
Here is the filter I am trying to combine
"query": {
"bool": {
"filter": [
{ "term": { "bien_type": "Appartment" }},
]
}
}
with this functional score functional and script field
query: {
function_score: {
functions: [
{
gauss: {
date_mutation: {
origin: "2019-12-31",
offset: "360d",
scale: "1800d",
decay: 0.1,
},
},
},
{
gauss: {
location: {
origin: { lat: latitude, lon: longitude },
offset: "0.1km",
scale: "0.9km",
decay: 0.1,
},
},
},
],
score_mode: "multiply",
},
},
_source: true,
script_fields: {
distance: {
script: {
inline: "doc['location'].arcDistance(params.lat,params.lon)",
lang: "painless",
params: {
lat: parseFloat(latitude),
lon: parseFloat(longitude),
},
},
},
},