Accessing doc fields in a scoring script

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

apologies, the preformatted text tool doesn't seem to like my code.

a "i" is missing in the date.getMills() ?

Thank you. In addition, I found I could use .value.millis instead of date.getMillis().

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.