Doc().numeric() sometimes returns empty for all objects

I wrote a custom search script which tries to access fields through
doc().field() (in this case, doc().numeric()).

I think I'm missing something obvious. I have a small sample --
https://github.com/cldellow/es-native-script/ -- that fetches lens.zoom
from the doc. The sample works fine.

In production, it doesn't reliably work. Items that definitely have values
for lens.zoom come back with a DocFieldData where .isEmpty() returns true.
The main difference in production is that the items and mappings have many
more fields. (You can click through to the history of the item and mapping
files in the github repo to see the full item/mapping)

What can cause this class of failure? The mapping in production must exist
and be correct, otherwise I would expect to see the "No field found for
[lens.zoom]" exception thrown from DocLookup.

Any ideas? I'm tearing my hair out trying to figure out what the heck is
going on.

Aha, I've figured out what's going on.

If a field in a document has the same name as a type in the index, the
mapper will use the type when resolving the mapping
(MapperService.smartNameObjectMapper). This results in the doc.numeric()
returning empty for all the values.

You can see this in the github repro I published -- as is, it works.
Uncomment the line in repro.sh that adds a mapping for 'lens', and it stops
working.

Is this expected, or a bug? I can work around it by ensuring my field names
don't clash with type names, but it seemed surprising to me.

On Wednesday, 13 June 2012 17:39:02 UTC-4, Colin Dellow wrote:

I wrote a custom search script which tries to access fields through
doc().field() (in this case, doc().numeric()).

I think I'm missing something obvious. I have a small sample --
https://github.com/cldellow/es-native-script/ -- that fetches lens.zoom
from the doc. The sample works fine.

In production, it doesn't reliably work. Items that definitely have values
for lens.zoom come back with a DocFieldData where .isEmpty() returns true.
The main difference in production is that the items and mappings have many
more fields. (You can click through to the history of the item and mapping
files in the github repo to see the full item/mapping)

What can cause this class of failure? The mapping in production must exist
and be correct, otherwise I would expect to see the "No field found for
[lens.zoom]" exception thrown from DocLookup.

Any ideas? I'm tearing my hair out trying to figure out what the heck is
going on.