Document fields in script

Hi,

Can someone please explain what "document fields" are when it comes to
custom_score scripts? I have a field 'foo' with store=yes which I would
like to base my custom score on. I also have "_source" : {"enabled" :
false} set. I can access the field using _fields['foo'].value but that
is too slow. In the docs it says " Document fields are very fast to
access since they end up being loaded into memory" so I would like to
use that instead but when I try doc['foo'].value I get a
"PropertyAccessException[[Error: null pointer" error. So how can I make
my field a "document field"?

Thanks
/Niklas

Yes, using doc will cause accessing the loaded field from memory (you don't
need to store it in this case). Not sure why you get the failure though,
can you gist a curl repro?

On Wed, Jun 13, 2012 at 4:25 PM, Niklas Therning niklas@therning.orgwrote:

Hi,

Can someone please explain what "document fields" are when it comes to
custom_score scripts? I have a field 'foo' with store=yes which I would
like to base my custom score on. I also have "_source" : {"enabled" :
false} set. I can access the field using _fields['foo'].value but that is
too slow. In the docs it says " Document fields are very fast to access
since they end up being loaded into memory" so I would like to use that
instead but when I try doc['foo'].value I get a
"PropertyAccessException[[Error: null pointer" error. So how can I make my
field a "document field"?

Thanks
/Niklas

I had index="no" on the field. Changing it to "not_analyzed" did the trick.

On 2012-06-14 23:35, Shay Banon wrote:

Yes, using doc will cause accessing the loaded field from memory (you
don't need to store it in this case). Not sure why you get the failure
though, can you gist a curl repro?

On Wed, Jun 13, 2012 at 4:25 PM, Niklas Therning <niklas@therning.org
mailto:niklas@therning.org> wrote:

Hi,

Can someone please explain what "document fields" are when it
comes to custom_score scripts? I have a field 'foo' with store=yes
which I would like to base my custom score on. I also have
"_source" : {"enabled" : false} set. I can access the field using
_fields['foo'].value but that is too slow. In the docs it says "
Document fields are very fast to access since they end up being
loaded into memory" so I would like to use that instead but when I
try doc['foo'].value I get a "PropertyAccessException[[Error: null
pointer" error. So how can I make my field a "document field"?

Thanks
/Niklas