# Geolocation documented methods missing distance, distanceInKm

**URL:** <https://discuss.elastic.co/t/geolocation-documented-methods-missing-distance-distanceinkm/4224>\
**Category:** Elasticsearch\
**Created:** [April 12, 2011, 9:04pm UTC](https://discuss.elastic.co/t/geolocation-documented-methods-missing-distance-distanceinkm/4224 "2011-04-12T21:04:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![speedopus](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@speedopus](https://discuss.elastic.co/u/speedopus)\
**Post date:** [April 12, 2011, 9:04pm UTC](https://discuss.elastic.co/t/geolocation-documented-methods-missing-distance-distanceinkm/4224/1 "2011-04-12T21:04:49Z")

</div>

For an acknowledged/mapped geo point type:

$ curl -XGET '[http://localhost:9200/edus/rpl\_edu/\_mapping?pretty=true](http://localhost:9200/edus/rpl_edu/_mapping?pretty=true)'  
{  
"edus" : {  
"rpl\_edu" : {  
"properties" : {  
"location" : {  
"type" : "geo\_point"  
},  
"paused" : { "type" : "boolean" }  
}  
}  
}  
}

Use of the documented methods for distance calculation:

[http://www.elasticsearch.org/guide/reference/modules/scripting.html](http://www.elasticsearch.org/guide/reference/modules/scripting.html)  
doc['field\_name'].distance(lat, lon) The distance (in miles) of this  
geo point field from the provided lat/lon.  
doc['field\_name'].distanceInKm(lat, lon) The distance (in km) of this  
geo point field from the provided lat/lon.

{"query" : {  
"custom\_score" : {  
"query" : {  
"field" : { "paused" : false }  
},  
"script" :"\_score \* doc['location'].distance(34,-118)"  
}  
}}

Seems to result in essentially a methodnotfound:

PropertyAccessException[[Error: unable to resolve method:  
org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()

(same happens for distanceInKm)

Any idea why this is? I am using 0.15.1.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 12, 2011, 9:25pm UTC](https://discuss.elastic.co/t/geolocation-documented-methods-missing-distance-distanceinkm/4224/2 "2011-04-12T21:25:30Z")

</div>

You script looks good, can you provide a simple curl recreation? The distance methods were added from version 0.15.0.  
On Wednesday, April 13, 2011 at 12:04 AM, Christopher Smith wrote:

> For an acknowledged/mapped geo point type:
> 
> $ curl -XGET '[http://localhost:9200/edus/rpl\_edu/\_mapping?pretty=true](http://localhost:9200/edus/rpl_edu/_mapping?pretty=true)'  
> {  
> "edus" : {  
> "rpl\_edu" : {  
> "properties" : {  
> "location" : {  
> "type" : "geo\_point"  
> },  
> "paused" : { "type" : "boolean" }  
> }  
> }  
> }  
> }
> 
> Use of the documented methods for distance calculation:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/modules/scripting.html)  
> doc['field\_name'].distance(lat, lon) The distance (in miles) of this  
> geo point field from the provided lat/lon.  
> doc['field\_name'].distanceInKm(lat, lon) The distance (in km) of this  
> geo point field from the provided lat/lon.
> 
> {"query" : {  
> "custom\_score" : {  
> "query" : {  
> "field" : { "paused" : false }  
> },  
> "script" :"\_score \* doc['location'].distance(34,-118)"  
> }  
> }}
> 
> Seems to result in essentially a methodnotfound:
> 
> PropertyAccessException[[Error: unable to resolve method:  
> org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()
> 
> (same happens for distanceInKm)
> 
> Any idea why this is? I am using 0.15.1.

---

<div class="post-metadata">

**Author:** ![speedopus](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@speedopus](https://discuss.elastic.co/u/speedopus)\
**Post date:** [April 12, 2011, 9:43pm UTC](https://discuss.elastic.co/t/geolocation-documented-methods-missing-distance-distanceinkm/4224/3 "2011-04-12T21:43:48Z")

</div>

Curl:

$ curl -XGET '[http://localhost:9200/edus/rpl\_edu/\_search?pretty=true](http://localhost:9200/edus/rpl_edu/_search?pretty=true)' -  
d @queryScriptFields.json  
{  
"error" : "SearchPhaseExecutionException[Failed to execute phase  
[query], total failure; shardFailures {[b1k0JkgsTleLjJYvA4VZvQ]  
[rpl\_edus][0]: QueryPhaseExecutionException[[rpl\_edus][0]:  
query[custom score  
(paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@6cdf3177)],from[0],size[10]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error:  
unable to resolve method:  
org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
[arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
\n ^\n[Line: 1, Column: 1]]; }{[b1k0JkgsTleLjJYvA4VZvQ]  
[rpl\_edus][1]: QueryPhaseExecutionException[[rpl\_edus][1]:  
query[custom score  
(paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@671ea47e)],from[0],size[10]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error:  
unable to resolve method:  
org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
[arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
\n ^\n[Line: 1, Column: 1]]; }{[b1k0JkgsTleLjJYvA4VZvQ]  
[rpl\_edus][2]: QueryPhaseExecutionException[[rpl\_edus][2]:  
query[custom score  
(paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@cc18116)],from[0],size[10]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error:  
unable to resolve method:  
org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
[arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
\n ^\n[Line: 1, Column: 1]]; }{[b1k0JkgsTleLjJYvA4VZvQ]  
[rpl\_edus][3]: QueryPhaseExecutionException[[rpl\_edus][3]:  
query[custom score  
(paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@7401d1e4)],from[0],size[10]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error:  
unable to resolve method:  
org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
[arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
\n ^\n[Line: 1, Column: 1]]; }{[b1k0JkgsTleLjJYvA4VZvQ]  
[rpl\_edus][4]: QueryPhaseExecutionException[[rpl\_edus][4]:  
query[custom score  
(paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@237b0b3c)],from[0],size[10]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error:  
unable to resolve method:  
org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
[arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
\n ^\n[Line: 1, Column: 1]]; }]",  
"status" : 500  
}

Where queryScriptFields.json is:  
{"query" : {  
"custom\_score" : {  
"query" : {  
"field" : { "paused" : false }  
},  
"script" :"\_score \* doc['location'].distance(34,-118)"  
}  
}}

And just for fun the log output:  
[2011-04-12 14:42:12,280][DEBUG][action.search.type] [War  
Eagle] [rpl\_edus][4], node[b1k0JkgsTleLjJYvA4VZvQ], [P], s[STARTED]:  
Failed to execute  
[org.elasticsearch.action.search.SearchRequest@2220f92c]  
org.elasticsearch.search.query.QueryPhaseExecutionException: [rpl\_edus]  
[4]: query[custom score  
(paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@58da27fe)],from[0],size[10]: Query Failed [Failed  
to execute main query]  
at  
org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:194)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:  
169)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:  
132)  
at  
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction  
$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:  
76)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction  
$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction  
$BaseAsyncAction.access$000(TransportSearchTypeAction.java:75)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction  
$BaseAsyncAction$1.run(TransportSearchTypeAction.java:150)  
at java.util.concurrent.ThreadPoolExecutor  
$Worker.runTask(ThreadPoolExecutor.java:886)  
at java.util.concurrent.ThreadPoolExecutor  
$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:619)  
Caused by: [Error: No field found for  
[org.elasticsearch.index.field.data.doubles.DoubleDocFieldData@fc8eb26]]  
[Near : {... (doc[amount].value/divisor)\*we ....}]  
^  
[Line: 1, Column: 1]  
at  
org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:  
427)  
at  
org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:  
140)  
at  
org.elasticsearch.common.mvel2.optimizers.dynamic.DynamicOptimizer.optimizeAccessor(DynamicOptimizer.java:  
66)  
at  
org.elasticsearch.common.mvel2.ast.ASTNode.optimize(ASTNode.java:158)  
at  
org.elasticsearch.common.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:  
115)  
at  
org.elasticsearch.common.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:  
116)  
at  
org.elasticsearch.common.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:  
38)  
at  
org.elasticsearch.common.mvel2.ast.Substatement.getReducedValueAccelerated(Substatement.java:  
42)  
at  
org.elasticsearch.common.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:  
116)  
at  
org.elasticsearch.common.mvel2.MVELRuntime.execute(MVELRuntime.java:  
87)  
at  
org.elasticsearch.common.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:  
125)  
at org.elasticsearch.script.mvel.MvelScriptEngineService  
$MvelSearchScript.run(MvelScriptEngineService.java:168)  
at org.elasticsearch.script.mvel.MvelScriptEngineService  
$MvelSearchScript.runAsFloat(MvelScriptEngineService.java:172)  
at  
org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction.score(CustomScoreQueryParser.java:119)  
at  
org.elasticsearch.common.lucene.search.function.FunctionScoreQuery  
$CustomBoostFactorScorer.score(FunctionScoreQuery.java:157)  
at org.apache.lucene.search.FilteredQuery  
$1$1.score(FilteredQuery.java:164)  
at org.apache.lucene.search.TopScoreDocCollector  
$InOrderTopScoreDocCollector.collect(TopScoreDocCollector.java:47)  
at org.apache.lucene.search.Scorer.score(Scorer.java:62)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:212)  
at  
org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:  
159)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:170)  
at org.apache.lucene.search.Searcher.search(Searcher.java:98)  
at org.apache.lucene.search.Searcher.search(Searcher.java:108)  
at  
org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:190)  
... 9 more  
Caused by: org.elasticsearch.ElasticSearchIllegalArgumentException: No  
field found for  
[org.elasticsearch.index.field.data.doubles.DoubleDocFieldData@fc8eb26]  
at  
org.elasticsearch.search.lookup.DocLookup.get(DocLookup.java:101)  
at  
org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getCollectionProperty(ReflectiveAccessorOptimizer.java:  
708)  
at  
org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:  
341)  
... 32 more

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 12, 2011, 9:47pm UTC](https://discuss.elastic.co/t/geolocation-documented-methods-missing-distance-distanceinkm/4224/4 "2011-04-12T21:47:44Z")

</div>

Check [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help). A curl recreation in this case will include the request that creates the index with the mapping, index data, and then executes the failed search request. And gist it.  
On Wednesday, April 13, 2011 at 12:43 AM, Christopher Smith wrote:

> Curl:
> 
> $ curl -XGET '[http://localhost:9200/edus/rpl\_edu/\_search?pretty=true](http://localhost:9200/edus/rpl_edu/_search?pretty=true)' -  
> d @queryScriptFields.json  
> {  
> "error" : "SearchPhaseExecutionException[Failed to execute phase  
> [query], total failure; shardFailures {[b1k0JkgsTleLjJYvA4VZvQ]  
> [rpl\_edus][0]: QueryPhaseExecutionException[[rpl\_edus][0]:  
> query[custom score  
> (paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
> $ScriptScoreFunction@6cdf3177)],from[0],size[10]: Query Failed [Failed  
> to execute main query]]; nested: PropertyAccessException[[Error:  
> unable to resolve method:  
> org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
> [arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
> \n ^\n[Line: 1, Column: 1]]; }{[b1k0JkgsTleLjJYvA4VZvQ]  
> [rpl\_edus][1]: QueryPhaseExecutionException[[rpl\_edus][1]:  
> query[custom score  
> (paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
> $ScriptScoreFunction@671ea47e)],from[0],size[10]: Query Failed [Failed  
> to execute main query]]; nested: PropertyAccessException[[Error:  
> unable to resolve method:  
> org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
> [arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
> \n ^\n[Line: 1, Column: 1]]; }{[b1k0JkgsTleLjJYvA4VZvQ]  
> [rpl\_edus][2]: QueryPhaseExecutionException[[rpl\_edus][2]:  
> query[custom score  
> (paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
> $ScriptScoreFunction@cc18116)],from[0],size[10]: Query Failed [Failed  
> to execute main query]]; nested: PropertyAccessException[[Error:  
> unable to resolve method:  
> org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
> [arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
> \n ^\n[Line: 1, Column: 1]]; }{[b1k0JkgsTleLjJYvA4VZvQ]  
> [rpl\_edus][3]: QueryPhaseExecutionException[[rpl\_edus][3]:  
> query[custom score  
> (paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
> $ScriptScoreFunction@7401d1e4)],from[0],size[10]: Query Failed [Failed  
> to execute main query]]; nested: PropertyAccessException[[Error:  
> unable to resolve method:  
> org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
> [arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
> \n ^\n[Line: 1, Column: 1]]; }{[b1k0JkgsTleLjJYvA4VZvQ]  
> [rpl\_edus][4]: QueryPhaseExecutionException[[rpl\_edus][4]:  
> query[custom score  
> (paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
> $ScriptScoreFunction@237b0b3c)],from[0],size[10]: Query Failed [Failed  
> to execute main query]]; nested: PropertyAccessException[[Error:  
> unable to resolve method:  
> org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
> [arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
> \n ^\n[Line: 1, Column: 1]]; }]",  
> "status" : 500  
> }
> 
> Where queryScriptFields.json is:  
> {"query" : {  
> "custom\_score" : {  
> "query" : {  
> "field" : { "paused" : false }  
> },  
> "script" :"\_score \* doc['location'].distance(34,-118)"  
> }  
> }}
> 
> And just for fun the log output:  
> [2011-04-12 14:42:12,280][DEBUG][action.search.type] [War  
> Eagle] [rpl\_edus][4], node[b1k0JkgsTleLjJYvA4VZvQ], [P], s[STARTED]:  
> Failed to execute  
> [org.elasticsearch.action.search.SearchRequest@2220f92c]  
> org.elasticsearch.search.query.QueryPhaseExecutionException: [rpl\_edus]  
> [4]: query[custom score  
> (paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
> $ScriptScoreFunction@58da27fe)],from[0],size[10]: Query Failed [Failed  
> to execute main query]  
> at  
> org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:194)  
> at  
> org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:  
> 169)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:  
> 132)  
> at  
> org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction  
> $AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:  
> 76)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction  
> $BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction  
> $BaseAsyncAction.access$000(TransportSearchTypeAction.java:75)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction  
> $BaseAsyncAction$1.run(TransportSearchTypeAction.java:150)  
> at java.util.concurrent.ThreadPoolExecutor  
> $Worker.runTask(ThreadPoolExecutor.java:886)  
> at java.util.concurrent.ThreadPoolExecutor  
> $Worker.run(ThreadPoolExecutor.java:908)  
> at java.lang.Thread.run(Thread.java:619)  
> Caused by: [Error: No field found for  
> [org.elasticsearch.index.field.data.doubles.DoubleDocFieldData@fc8eb26]]  
> [Near : {... (doc[amount].value/divisor)\*we ....}]  
> ^  
> [Line: 1, Column: 1]  
> at  
> org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:  
> 427)  
> at  
> org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:  
> 140)  
> at  
> org.elasticsearch.common.mvel2.optimizers.dynamic.DynamicOptimizer.optimizeAccessor(DynamicOptimizer.java:  
> 66)  
> at  
> org.elasticsearch.common.mvel2.ast.ASTNode.optimize(ASTNode.java:158)  
> at  
> org.elasticsearch.common.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:  
> 115)  
> at  
> org.elasticsearch.common.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:  
> 116)  
> at  
> org.elasticsearch.common.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:  
> 38)  
> at  
> org.elasticsearch.common.mvel2.ast.Substatement.getReducedValueAccelerated(Substatement.java:  
> 42)  
> at  
> org.elasticsearch.common.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:  
> 116)  
> at  
> org.elasticsearch.common.mvel2.MVELRuntime.execute(MVELRuntime.java:  
> 87)  
> at  
> org.elasticsearch.common.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:  
> 125)  
> at org.elasticsearch.script.mvel.MvelScriptEngineService  
> $MvelSearchScript.run(MvelScriptEngineService.java:168)  
> at org.elasticsearch.script.mvel.MvelScriptEngineService  
> $MvelSearchScript.runAsFloat(MvelScriptEngineService.java:172)  
> at  
> org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
> $ScriptScoreFunction.score(CustomScoreQueryParser.java:119)  
> at  
> org.elasticsearch.common.lucene.search.function.FunctionScoreQuery  
> $CustomBoostFactorScorer.score(FunctionScoreQuery.java:157)  
> at org.apache.lucene.search.FilteredQuery  
> $1$1.score(FilteredQuery.java:164)  
> at org.apache.lucene.search.TopScoreDocCollector  
> $InOrderTopScoreDocCollector.collect(TopScoreDocCollector.java:47)  
> at org.apache.lucene.search.Scorer.score(Scorer.java:62)  
> at  
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:212)  
> at  
> org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:  
> 159)  
> at  
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:170)  
> at org.apache.lucene.search.Searcher.search(Searcher.java:98)  
> at org.apache.lucene.search.Searcher.search(Searcher.java:108)  
> at  
> org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:190)  
> ... 9 more  
> Caused by: org.elasticsearch.ElasticSearchIllegalArgumentException: No  
> field found for  
> [org.elasticsearch.index.field.data.doubles.DoubleDocFieldData@fc8eb26]  
> at  
> org.elasticsearch.search.lookup.DocLookup.get(DocLookup.java:101)  
> at  
> org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getCollectionProperty(ReflectiveAccessorOptimizer.java:  
> 708)  
> at  
> org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:  
> 341)  
> ... 32 more

---

<div class="post-metadata">

**Author:** ![speedopus](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@speedopus](https://discuss.elastic.co/u/speedopus)\
**Post date:** [April 12, 2011, 9:47pm UTC](https://discuss.elastic.co/t/geolocation-documented-methods-missing-distance-distanceinkm/4224/5 "2011-04-12T21:47:50Z")

</div>

Curl:

$ curl -XGET '[http://localhost:9200/edus/rpl\_edu/\_search?pretty=true](http://localhost:9200/edus/rpl_edu/_search?pretty=true)' -  
d @queryScriptFields.json  
{  
"error" : "SearchPhaseExecutionException[Failed to execute phase  
[query], total failure; shardFailures {[b1k0JkgsTleLjJYvA4VZvQ]  
[rpl\_edus][0]: QueryPhaseExecutionException[[rpl\_edus][0]:  
query[custom score  
(paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@6cdf3177)],from[0],size[10]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error:  
unable to resolve method:  
org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
[arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
\n ^\n[Line: 1, Column: 1]]; }{[b1k0JkgsTleLjJYvA4VZvQ]  
[rpl\_edus][1]: QueryPhaseExecutionException[[rpl\_edus][1]:  
query[custom score  
(paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@671ea47e)],from[0],size[10]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error:  
unable to resolve method:  
org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
[arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
\n ^\n[Line: 1, Column: 1]]; }{[b1k0JkgsTleLjJYvA4VZvQ]  
[rpl\_edus][2]: QueryPhaseExecutionException[[rpl\_edus][2]:  
query[custom score  
(paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@cc18116)],from[0],size[10]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error:  
unable to resolve method:  
org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
[arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
\n ^\n[Line: 1, Column: 1]]; }{[b1k0JkgsTleLjJYvA4VZvQ]  
[rpl\_edus][3]: QueryPhaseExecutionException[[rpl\_edus][3]:  
query[custom score  
(paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@7401d1e4)],from[0],size[10]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error:  
unable to resolve method:  
org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
[arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
\n ^\n[Line: 1, Column: 1]]; }{[b1k0JkgsTleLjJYvA4VZvQ]  
[rpl\_edus][4]: QueryPhaseExecutionException[[rpl\_edus][4]:  
query[custom score  
(paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@237b0b3c)],from[0],size[10]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error:  
unable to resolve method:  
org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
[arglength=0]]\n[Near : {... \_score \* doc['location'].dista ....}]  
\n ^\n[Line: 1, Column: 1]]; }]",  
"status" : 500  
}

Where queryScriptFields.json contains:  
{"query" : {  
"custom\_score" : {  
"query" : {  
"field" : { "paused" : false }  
},  
"script" :"\_score \* doc['location'].distance(34,-118)"  
}  
}}

And just for fun the log output:  
[2011-04-12 14:46:47,894][DEBUG][action.search.type] [War  
Eagle] [edus][4], node[b1k0JkgsTleLjJYvA4VZvQ], [P], s[STARTED]:  
Failed to execute  
[org.elasticsearch.action.search.SearchRequest@7ab4753b]  
org.elasticsearch.search.query.QueryPhaseExecutionException: [rpl\_edus]  
[4]: query[custom score  
(paused:F,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@101853a4)],from[0],size[10]: Query Failed [Failed  
to execute main query]  
at  
org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:194)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:  
169)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:  
132)  
at  
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction  
$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:  
76)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction  
$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction  
$BaseAsyncAction.access$000(TransportSearchTypeAction.java:75)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction  
$BaseAsyncAction$1.run(TransportSearchTypeAction.java:150)  
at java.util.concurrent.ThreadPoolExecutor  
$Worker.runTask(ThreadPoolExecutor.java:886)  
at java.util.concurrent.ThreadPoolExecutor  
$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:619)  
Caused by: [Error: unable to resolve method:  
org.elasticsearch.index.mapper.xcontent.geo.GeoPointDocFieldData.distance()  
[arglength=0]]  
[Near : {... \_score \* doc['location'].dista ....}]  
^  
[Line: 1, Column: 1]  
at  
org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:  
1006)  
at  
org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:  
338)  
at  
org.elasticsearch.common.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:  
140)  
at  
org.elasticsearch.common.mvel2.optimizers.dynamic.DynamicOptimizer.optimizeAccessor(DynamicOptimizer.java:  
66)  
at  
org.elasticsearch.common.mvel2.ast.ASTNode.optimize(ASTNode.java:158)  
at  
org.elasticsearch.common.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:  
115)  
at  
org.elasticsearch.common.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:  
116)  
at  
org.elasticsearch.common.mvel2.MVELRuntime.execute(MVELRuntime.java:  
87)  
at  
org.elasticsearch.common.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:  
125)  
at org.elasticsearch.script.mvel.MvelScriptEngineService  
$MvelSearchScript.run(MvelScriptEngineService.java:168)  
at org.elasticsearch.script.mvel.MvelScriptEngineService  
$MvelSearchScript.runAsFloat(MvelScriptEngineService.java:172)  
at  
org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction.score(CustomScoreQueryParser.java:119)  
at  
org.elasticsearch.common.lucene.search.function.FunctionScoreQuery  
$CustomBoostFactorScorer.score(FunctionScoreQuery.java:157)  
at org.apache.lucene.search.FilteredQuery  
$1$1.score(FilteredQuery.java:164)  
at org.apache.lucene.search.TopScoreDocCollector  
$InOrderTopScoreDocCollector.collect(TopScoreDocCollector.java:47)  
at org.apache.lucene.search.Scorer.score(Scorer.java:62)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:212)  
at  
org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:  
159)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:170)  
at org.apache.lucene.search.Searcher.search(Searcher.java:98)  
at org.apache.lucene.search.Searcher.search(Searcher.java:108)  
at  
org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:190)  
... 9 more

---

<div class="post-metadata">

**Author:** ![speedopus](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@speedopus](https://discuss.elastic.co/u/speedopus)\
**Post date:** [April 12, 2011, 10:30pm UTC](https://discuss.elastic.co/t/geolocation-documented-methods-missing-distance-distanceinkm/4224/6 "2011-04-12T22:30:48Z")

</div>

Well now I am doubly confused. Here is the gist: [https://gist.github.com/916564](https://gist.github.com/916564)

BUT - in building this up I saw I didn't get the error. Thought maybe  
it was due to my windows box so I tried with a new index against the  
centos server - no error. Totally baffled - same installation -  
different index.

The search SHOULD still work - I believe - but I was very confused as  
to why my index throws up that error but a test index does not. The  
only real difference is the real index is build up using the java api,  
not curl, far as I am aware.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 12, 2011, 10:40pm UTC](https://discuss.elastic.co/t/geolocation-documented-methods-missing-distance-distanceinkm/4224/7 "2011-04-12T22:40:01Z")

</div>

It also does not look like you use the same forumal. In terms of windows vs. centos, or Java API vs, REST API, there is no difference, REST API uses the Java API under the covers, and, at least for this case, does not seem like OS should make a difference.

Indeed, strange...  
On Wednesday, April 13, 2011 at 1:30 AM, Christopher Smith wrote:

> Well now I am doubly confused. Here is the gist: [Trouble with geo distance · GitHub](https://gist.github.com/916564)
> 
> BUT - in building this up I saw I didn't get the error. Thought maybe  
> it was due to my windows box so I tried with a new index against the  
> centos server - no error. Totally baffled - same installation -  
> different index.
> 
> The search SHOULD still work - I believe - but I was very confused as  
> to why my index throws up that error but a test index does not. The  
> only real difference is the real index is build up using the java api,  
> not curl, far as I am aware.

---

<div class="post-metadata">

**Author:** ![speedopus](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@speedopus](https://discuss.elastic.co/u/speedopus)\
**Post date:** [April 12, 2011, 11:49pm UTC](https://discuss.elastic.co/t/geolocation-documented-methods-missing-distance-distanceinkm/4224/8 "2011-04-12T23:49:21Z")

</div>

Do you have any suggestions on how I might go about further testing to  
uncover the issue?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 13, 2011, 7:55am UTC](https://discuss.elastic.co/t/geolocation-documented-methods-missing-distance-distanceinkm/4224/9 "2011-04-13T07:55:14Z")

</div>

Maybe try and create and index sample data the way you did with the original index? The API is not different elasticsearch wise, but, maybe the code you execute is different.  
On Wednesday, April 13, 2011 at 2:49 AM, Christopher Smith wrote:

> Do you have any suggestions on how I might go about further testing to  
> uncover the issue?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:08am UTC](https://discuss.elastic.co/t/geolocation-documented-methods-missing-distance-distanceinkm/4224/10 "2017-07-06T04:08:26Z")

</div>


