Hi everyone, 

I've been playing around with the new spatial search functionalities
included in the newer versions of solr (solr 4.1 and solr trunk 5.0), and
i've found something strange when I try to find a point inside a polygon
(particularly inside a square).

You can reproduce this problem using the spatial-solr-sandbox project that
has the following config for the fields:

/[...]
<fieldType name="geohash"   class="solr.SpatialRecursivePrefixTreeFieldType"
units="degrees" />
[...]
<field name="geohash"  type="geohash"  indexed="true" stored="true" 
multiValued="false" />
[...]/

I'm trying to find the following document:

/<doc>
        <str name="id">G292223</str>
        <str name="name">Dubai</str>
        <str name="geohash">55.280000 25.252220</str>
</doc>
/
I want to test if this point is located inside a polygon so i'm using the
following query:

/q=geohash:"Intersects(POLYGON((55.180000 25.352220,55.380000
25.352220,55.380000 25.152220,55.180000 25.152220,55.180000 25.352220)))"/

As you can see, it's a small square that contains the point described
before. I get some results, but that document is not there, and the ones
returned are wrong since they are not even inside the square.

/<result name="response" numFound="8" start="0">
        <doc>
                <str name="id">G1809498</str>
                <str name="name">Guilin</str>
                <str name="geohash">110.286390 25.281940</str>
        </doc>
        
        [...]/

However, if i change a little bit the shape of the square (just changed a
little bit one corner), it returns the result as expected

/q=geohash:"Intersects(POLYGON((55.180000 25.352220,*55.480000*
25.352220,55.380000 25.152220,55.180000 25.152220,55.180000 25.352220)))"/

Now it returns a single result and it's OK

/<result name="response" numFound="1" start="0">
        <doc>
                <str name="id">G292223</str>
                <str name="name">Dubai</str>
                <str name="geohash">55.280000 25.252220</str>
        </doc>
</result>/


If i use a bbox with the same size and position than the first square, it
returns correctly the document.

/q=geohash:"Intersects(55.180000 25.152220 55.380000 25.352220)"

<result name="response" numFound="1" start="0">
        <doc>
                <str name="id">G292223</str>
                <str name="name">Dubai</str>
                <str name="geohash">55.280000 25.252220</str>
        </doc>
</result>/

If you draw another polygon such a triangle it works well too.

I've tested this against different points and it's always the same, it seems
that if you draw a straight square (or rectangle),
it can't find the point inside it, and it returns wrong results.

Am i doing anything wrong?

Thanks in advance

Jorge



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solr-4-spatial-search-point-intersects-polygon-tp4012402.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to