I am newbie to ES. I was trying to write java program to do geosearch using ES against MongoDB(installed river plugin etc and able to get the normal search using java program). I have a collection (table) in mongodb which has latitide and longitude values stored.Now I want to retreive the records based on lat and long which I am passing from Java program.
FilterBuilder filter = FilterBuilders.geoDistanceFilter("pin.location").lat(10).lon(20).distance(5,DistanceUnit.KILOMETERS).geoDistance(GeoDistance.PLANE);
SearchResponse response = client.prepareSearch(INDEX)
.setTypes(TYPE)
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(matchAllQuery())
.setPostFilter(filter)
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();
If I execute the above program, I am getting " QueryParsingException[[mongoindex] failed to find geo_point field [pin.location]];" what is this pin.location? Also my mongodb table has columns 'Latitude" and 'Longitude'. But in the above filter I have 'lat(10).lon(20)'. I am missing something here. Please help me to understand. Any quick help highly appreciated.
Full stack tarce:
},"explain":true}]]]; nested: QueryParsingException[[mongoindex] failed to find geo_point field [pin.location]]; } at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:233) at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$1.onFailure(TransportSearchTypeAction.java:179) at org.elasticsearch.search.action.SearchServiceTransportAction$12.handleException(SearchServiceTransportAction.java:351) at org.elasticsearch.transport.netty.MessageChannelHandler.handleException(MessageChannelHandler.java:185) at org.elasticsearch.transport.netty.MessageChannelHandler.handlerResponseError(MessageChannelHandler.java:175) at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:125) at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) at org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791) at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:296) at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462) at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443) at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303) at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:268) at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:255) at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88) at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108) at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318) at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
Thanks, Sri
http://url-to-es/index/document?query=...
– Nir Alfasi