Accessing document fields from preloaded script

I'm trying to use a preloaded javascript file stored in
/config/scripts/test.js

http://www.elasticsearch
.org/guide/reference/query-dsl/custom-score-query.html

I'm using the Tire gem for Rails integration.

query do
custom_score :params => {:stuck_out_tongue: => 5}, :script => "test", :lang => "js" do
string '*'
end
end

test.js:
java.lang.System.out.println(doc['components'].value)
5

I want to access one of my document fields (type is text), but the output
of doc['components'].value is just 0. What might be the problem here?

Thanks!

--

I don't see anything particularly wrong with your sample. When
doc['some_field'].value returns 0, it might indicate that 'some_field' is
mapped as integer and is missing for the given record. But since you have
stated that the field "components" is indexed as text, I am not really sure
what it might be. Are you restarting elasticsearch every time you update
the script? If yes, could you provide a short repro of this issue?

On Wednesday, December 5, 2012 2:59:38 PM UTC-5, George Xing wrote:

I'm trying to use a preloaded javascript file stored in
/config/scripts/test.js

http://www.elasticsearch
.org/guide/reference/query-dsl/custom-score-query.html

I'm using the Tire gem for Rails integration.

query do
custom_score :params => {:stuck_out_tongue: => 5}, :script => "test", :lang => "js" do
string '*'
end
end

test.js:
java.lang.System.out.println(doc['components'].value)
5

I want to access one of my document fields (type is text), but the output
of doc['components'].value is just 0. What might be the problem here?

Thanks!

--