Check field existence in JSON using script

Hi,

I am Using - Elasticsearch 0.19.11.

Using script for CustomScoring.

Used the below script for existence of field and according to that giving
score.
String script = "(doc['testid'].empty?100:1)*_score";

But it shows below error.

Caused by: [Error: No field found for [testid] in mapping with types []]
[Near : {... (doc['testid'].empty?100:1)*_sco ....}]

Caused by: org.elasticsearch.ElasticSearchIllegalArgumentException: No
field found for [testid] in mapping with types []
at org.elasticsearch.search.lookup.DocLookup.get(DocLookup.java:116)
at
org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getCollectionProperty(ReflectiveAccessorOptimizer.java:761)
at
org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:347)

Is the above script (doc['testid'].empty?100:1) correct for checking field
existence ? Or any other method?
Please give me some solution.

Thanks in advance,
Thanuja.G

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.