I suspect there is an easy answer to this, but I've searched and not found an explanation. The problem is when I add a params block to my scoring function I can no longer access doc fields.
For example (I'm using the Ruby DSL), the following works fine:
this_works = search {
query do
function_score do
query do
match_all
end
functions << {
script_score: {
script: {
source: "doc['last_sold'].date.getMillis()"
}
}
}
end
end
size 100
}
However, the following throws the error "No field found for [last_sold]in mapping with types []":
this_does_not_work = search {
query do
function_score do
query do
match_all
end
functions << {
script_score: {
script: {
params: {
something: 1
},
source: "doc['last_sold'].date.getMills() + params.something"
}
}
}
end
end
size 100
}
Thanks in advance.
Mark