Hi. It's clear there is an ordering problem in your latitudes and longitudes. If indeed you intend to index latitude 9.44Š and longitude 76.45Š as you said, then you are indexing it correctly. You may also choose to index in WKT format, which would be POINT(76.45 9.44) but either is fine. However your query shape shows that you have latitudes and longitudes in the wrong order. Your query shape is in WKT format, and WKT is in "x y" order. Yet you have given it in latitude longitude order which is reversed.
Another observation is that you are using the "IsWithin" predicate. There isn't anything wrong with that, but if all of your indexed data is points, and you only need at least some of a document's multi-valued point data to be in the shape for a match (I.e. You don't care if one point is in but another is out for the same document), then "Intersects" is much faster. IsWithin must look in all places outside your shape (in addition to inside) to attempt to ensure it doesn't include external data. ~ David On 11/15/13 1:36 AM, "Dhanesh Radhakrishnan" <dhan...@hifx.co.in> wrote: >Hi, >I'm experimenting with solr spatial search, with plotting points in the >map >(Latitude and longitude) and based on the value I need to get the result. > >As the first step I've defined the filed type as ><fieldType name="location_rpt" >class="solr.SpatialRecursivePrefixTreeFieldType" >spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFac >tory" >distErrPct="0.025" maxDistErr="0.000009" units="degrees" /> > >And then added the field *location* as type *location_rpt* > <field name="location" type="location_rpt" indexed="true" stored="true" >multiValued="true" /> > >Indexed the location filed as $latitude, $longitude So that data in the >*location* will be like > >"location":["9.445890,76.540970"] > >Next I draw a polygon in google map and collected the lat and lng >coordinates of the polygon. >It will be like >9.472992 76.540817, 9.441328 76.523651 , 9.433708 76.555065 , 9.458092 >76.572403, 9.472992 76.540817 > >Based on this coordinates I performed a query in solr like this >localhost:8983/solr/ha_poc/select?fl=id,name,district,locality&wt=json& >json.nl=map&q=*:*&fq=location:"IsWithin(POLYGON((9.472992 76.540817, >9.441328 76.523651 , 9.433708 76.555065 , 9.458092 76.572403, 9.472992 >76.540817))) distErrPct=0" > > >But I didn't get the result from the solr as I expected. > >{ > > - "responseHeader": { > - "status": 0, > - "QTime": 2 > }, > - "response": { > - "numFound": 0, > - "start": 0, > - "docs": [ ] > } > >} > > >Is there anything that I missed ??? >Can anybody help me in solving this issue with solr spatial search. >I'm using Solr 4.4.0 >Added an additional dependency JTS jar file for the support of polygon >/lib/ext/jts-1.13.jar > >-- >*dhanesh s.r*