You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Marian Steinbach <ma...@sendung.de> on 2012/02/09 15:36:24 UTC

Geospatial search with multivalued field

Hi!

I'm trying to figure out how to enable spatial search for my use case.

I have documents that are in many cases associated with multiple geo
locations. I'd like to filter documents by the minimum distance to a
reference point (which is given at query time).

What this means is: If at least one of the locations of a document
lies within a certain radius of the point, it should be included in
the result.

Which field type can I use for this and how would I have to do the filtering?

Sorting (by distance) isn't relevant at this point, but it might be in
the future.

The example in Solr 3.4 states in schema.xml for the fieldType
"location" (field "store"): "A specialized field for geospatial
search. If indexed, this fieldType must not be multivalued." If I used
a field of type solr.LatLonType this would mean that I could have
multivalued="true", but no indexing? This means that I couldn't do
fast bounding box / range queries on the locations in order to narrow
down the result for a distance filter, correct? So wich one is better?

Thanks!

Marian

Re: Geospatial search with multivalued field

Posted by "David Smiley (@MITRE.org)" <DS...@mitre.org>.
Hi Marian.  I'm the author of Solr2155.
  SpatialQueryable is an interface provided by Solr.  Where did you put the
SOLR-2155 built jar file?  Perhaps you put it where it doesn't belong like
in your servlet engine's lib directory (varies).  You can put this in a
variety of places like embedding it into the Solr war, or in a shared lib
folder referenced by solr.xml or in a lib folder adjacent to your core's
conf directory, or finally any place referenced by a <lib> entry in
solrconfig.xml.

And you need a 3x release of Solr; trunk won't work for this.

~ David


-----
 Author: http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
--
View this message in context: http://lucene.472066.n3.nabble.com/Geospatial-search-with-multivalued-field-tp3729648p3737995.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Geospatial search with multivalued field

Posted by Marian Steinbach <ma...@sendung.de>.
Seems like I moved to the next failure. Now I get

    java.lang.NoClassDefFoundError: org/apache/solr/schema/SpatialQueryable

during solr startup. Any idea where this sould be?

It seems to be required by the path
(src/main/java/solr2155/solr/schema/GeoHashField.java:public class
GeoHashField extends FieldType implements SpatialQueryable) but not
provided within the ZIP.

Marian

Re: Geospatial search with multivalued field

Posted by Marian Steinbach <ma...@sendung.de>.
2012/2/12 Mikhail Khludnev <mk...@griddynamics.com>:
> Marian,
>
> My experience is not applicable to you directly, but David says
>
>  You'll need to run "mvn package" to generate a jar file that you can throw
> into your classpath.
>
> Have you got the jar ? You don't need to bother with Solr sources. Just
> build jar and put it into Solr libs (see
> http://wiki.apache.org/solr/SolrConfigXml#lib for reference). After that
> amend you solrconfig/schema.xmls IIRC.

I tried "mvn package" without success. The error message wasn't clear
to me at first and I thought it was due to the wrong locations etc.

Then I found out that the .m2 directory in my home dir hat the wrong
write permissions, which caused the errors.

Now it worked. I gut the jar built. Will test geo filtering now or tomorrow.

Thanks again!

Marian

Re: Geospatial search with multivalued field

Posted by Mikhail Khludnev <mk...@griddynamics.com>.
Marian,

My experience is not applicable to you directly, but David says

 You'll need to run "mvn package" to generate a jar file that you can throw
into your classpath.

Have you got the jar ? You don't need to bother with Solr sources. Just
build jar and put it into Solr libs (see
http://wiki.apache.org/solr/SolrConfigXml#lib for reference). After that
amend you solrconfig/schema.xmls IIRC.

Regards

On Sat, Feb 11, 2012 at 12:44 AM, Marian Steinbach <ma...@sendung.de>wrote:

> 2012/2/10 Mikhail Khludnev <mk...@griddynamics.com>:
> > Marian,
> >
> > Sorry, I completely forgot to mention.
> > Pls check David's instruction
> >
> https://issues.apache.org/jira/browse/SOLR-2155?focusedCommentId=13117350&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13117350
> >
> > The patch you tried to use is just my amendment for the David's zip. In
> > according to his comment it's already in Solr2155-1.0.3-project.zip.
>
> Mikhail, thank you! That explains a lot.
>
> With the ZIP project, I still can't figure out where to put it and
> what to apply it to. Do I have to put it into the 3.4.0-src folder
> hierarchy? If yes, where exactly?
>
> Marian
>



-- 
Sincerely yours
Mikhail Khludnev
Lucid Certified
Apache Lucene/Solr Developer
Grid Dynamics

<http://www.griddynamics.com>
 <mk...@griddynamics.com>

Re: Geospatial search with multivalued field

Posted by Marian Steinbach <ma...@sendung.de>.
2012/2/10 Mikhail Khludnev <mk...@griddynamics.com>:
> Marian,
>
> Sorry, I completely forgot to mention.
> Pls check David's instruction
> https://issues.apache.org/jira/browse/SOLR-2155?focusedCommentId=13117350&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13117350
>
> The patch you tried to use is just my amendment for the David's zip. In
> according to his comment it's already in Solr2155-1.0.3-project.zip.

Mikhail, thank you! That explains a lot.

With the ZIP project, I still can't figure out where to put it and
what to apply it to. Do I have to put it into the 3.4.0-src folder
hierarchy? If yes, where exactly?

Marian

Re: Geospatial search with multivalued field

Posted by Mikhail Khludnev <mk...@griddynamics.com>.
Marian,

Sorry, I completely forgot to mention.
Pls check David's instruction
https://issues.apache.org/jira/browse/SOLR-2155?focusedCommentId=13117350&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13117350

The patch you tried to use is just my amendment for the David's zip. In
according to his comment it's already in Solr2155-1.0.3-project.zip.

Regards

On Fri, Feb 10, 2012 at 5:32 PM, Marian Steinbach <ma...@sendung.de> wrote:

> 2012/2/9 Mikhail Khludnev <mk...@griddynamics.com>:
> > Some time ago I tested backported patch from
> > https://issues.apache.org/jira/browse/SOLR-2155
> > it works.
>
> OK, I would do that. But...
>
> Against which version can/should I apply the patch? (I am not
> restricted by other requirements so far.)
>
> Then I tried both with the trunk and with 3.4.0-src, but I can't even
> find the files the patch wants to modify. Some are moved, but others
> don't exist.
>
> Some of the files mentioned in the patch can be
> solr/src/java/org/apache/solr/search/QParserPlugin.java
> => solr/core/src/java/org/apache/solr/search/QParserPlugin.java
>
> solr/src/test/org/apache/solr/search/SpatialFilterTest.java
> => solr/core/src/test/org/apache/solr/search/SpatialFilterTest.java
>
>
> lucene/contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/MultiGeom.java
> => not found at all.
>
> This was all for
> "SOLR-2155_GeoHashPrefixFilter_with_sorting_no_poly.patch".
>
> For the file "Solr2155-for-1.0.2-3.x-port.patch", similar things
> happen. E.g. "HaversineMultiConstFunction.java" isn't anywhere in the
> 3.4.0 src tarball.
>
> What would I have to do in order to get any Solr version patched with 2155?
>
> Thanks!
>
> Marian
>



-- 
Sincerely yours
Mikhail Khludnev
Lucid Certified
Apache Lucene/Solr Developer
Grid Dynamics

<http://www.griddynamics.com>
 <mk...@griddynamics.com>

Re: Geospatial search with multivalued field

Posted by Marian Steinbach <ma...@sendung.de>.
2012/2/9 Mikhail Khludnev <mk...@griddynamics.com>:
> Some time ago I tested backported patch from
> https://issues.apache.org/jira/browse/SOLR-2155
> it works.

OK, I would do that. But...

Against which version can/should I apply the patch? (I am not
restricted by other requirements so far.)

Then I tried both with the trunk and with 3.4.0-src, but I can't even
find the files the patch wants to modify. Some are moved, but others
don't exist.

Some of the files mentioned in the patch can be
solr/src/java/org/apache/solr/search/QParserPlugin.java
=> solr/core/src/java/org/apache/solr/search/QParserPlugin.java

solr/src/test/org/apache/solr/search/SpatialFilterTest.java
=> solr/core/src/test/org/apache/solr/search/SpatialFilterTest.java

lucene/contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/MultiGeom.java
=> not found at all.

This was all for "SOLR-2155_GeoHashPrefixFilter_with_sorting_no_poly.patch".

For the file "Solr2155-for-1.0.2-3.x-port.patch", similar things
happen. E.g. "HaversineMultiConstFunction.java" isn't anywhere in the
3.4.0 src tarball.

What would I have to do in order to get any Solr version patched with 2155?

Thanks!

Marian

Re: Geospatial search with multivalued field

Posted by Mikhail Khludnev <mk...@griddynamics.com>.
Some time ago I tested backported patch from
https://issues.apache.org/jira/browse/SOLR-2155
it works.

Regards

On Thu, Feb 9, 2012 at 6:36 PM, Marian Steinbach <ma...@sendung.de> wrote:

> Hi!
>
> I'm trying to figure out how to enable spatial search for my use case.
>
> I have documents that are in many cases associated with multiple geo
> locations. I'd like to filter documents by the minimum distance to a
> reference point (which is given at query time).
>
> What this means is: If at least one of the locations of a document
> lies within a certain radius of the point, it should be included in
> the result.
>
> Which field type can I use for this and how would I have to do the
> filtering?
>
> Sorting (by distance) isn't relevant at this point, but it might be in
> the future.
>
> The example in Solr 3.4 states in schema.xml for the fieldType
> "location" (field "store"): "A specialized field for geospatial
> search. If indexed, this fieldType must not be multivalued." If I used
> a field of type solr.LatLonType this would mean that I could have
> multivalued="true", but no indexing? This means that I couldn't do
> fast bounding box / range queries on the locations in order to narrow
> down the result for a distance filter, correct? So wich one is better?
>
> Thanks!
>
> Marian
>



-- 
Sincerely yours
Mikhail Khludnev
Lucid Certified
Apache Lucene/Solr Developer
Grid Dynamics

<http://www.griddynamics.com>
 <mk...@griddynamics.com>