With a painless scripted field, the recommended field presence logic itself causes a "No field found" error, but not on all records - in fact just four of ~930k fail with the error (below).
However, for many other other documents that do not have a destination_geo.asn field, the scripted field as stated above works properly.
I experimented with using doc.containsKey() as indicated here. The four failing records work fine with this function but all other records missing a destination_geo.asn field fail.
This sounds like you're missing a mapping for destination_geo.asn in one of your indices. Is that the case?
When there's a mapping for a field, doc['destination_geo.asn'].size() == 0 is the best way to check if a value is missing for the field in a document.
If there is no mapping for a field, things are trickier, you have to check !doc.containsKey('destination_geo.asn')before checking doc['destination_geo.asn'].size() == 0.
The mapping ensures the destination_geo.asn exists in doc.
To put it together, try the following:
if (!doc.containsKey('destination_geo.asn') || doc['destination_geo.asn'].size() == 0 ....
If that doesn't work, it'd help to see your mappings and more of your script.
I used the dual verification syntax with both !doc.containsKey('x') and doc['x'].size() == 0 and it worked ok. however, I'm pretty puzzled as to why the mapping was not applied to the adjacent indices.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.