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 SR <r....@gmail.com> on 2011/07/09 02:16:52 UTC
SolrJ & Spatial Search
Hi there,
Through SolrJ 3.2, I'm trying to set some Spatial Search queries (e.g., filter by distance, sort by distance, etc.). I don’t know whether there's a specific SolrJ syntax to do this. I tried using Strings, but it’s not working. Here’s are two examples that work fine on Solr, but don’t work when I use SolrJ:
Example 1:
…
String q = "{!func}geodist()&sfield=store&pt=” + lat + “,” + lon +”&sort=score asc";
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQuery(q);
…
Using SolrJ, I get the following error.
…
org.apache.lucene.queryParser.ParseException: geodist - not enough parameters:[]
Example 2:
…
String q = "*:*&sfield=store&sort=geodist() asc&pt=” + lat + “,” + lon;
…
Using SolrJ, I get the following error
…
Caused by: org.apache.solr.common.SolrException: undefined field *
Do you know how to set these kinds of queries using SolrJ?
Thanks in advance for your help,
-S
Re: SolrJ & Spatial Search
Posted by "David Smiley (@MITRE.org)" <DS...@mitre.org>.
solrQuery.setQuery("*:*");
solrQuery.addFilterQuery("{!func}geodist()");
solrQuery.set("sfield", "store");
solrQuery.set("pt", lat + "," + lon);
solrQuery.set("sort", "geodist() asc");
//disclaimer: I haven't run this
-----
Author: https://www.packtpub.com/solr-1-4-enterprise-search-server/book
--
View this message in context: http://lucene.472066.n3.nabble.com/Spatial-search-with-SolrJ-3-1-How-to-tp2961136p3259743.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: SolrJ & Spatial Search
Posted by "federico.wachs" <fe...@2clams.com>.
I'm sorry, i'm trying to do the same as he is.
I've read your reply many times now, but i still don't know how to do this.
Would somebody help me with this? Thanks a lot
--
View this message in context: http://lucene.472066.n3.nabble.com/Spatial-search-with-SolrJ-3-1-How-to-tp2961136p3259456.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: SolrJ & Spatial Search
Posted by "David Smiley (@MITRE.org)" <DS...@mitre.org>.
Saïd,
The misunderstanding you have is that you are confusing the user query (the
q parameter) with the URL that Solr sees. Well actually the part of the URL
that is called the query string -- that which is after the "?". SolrQuery
has various setters for well-known parameters, and others just use
solrQuery.setParam(name,value).
~ David Smiley
-----
Author: https://www.packtpub.com/solr-1-4-enterprise-search-server/book
--
View this message in context: http://lucene.472066.n3.nabble.com/Spatial-search-with-SolrJ-3-1-How-to-tp2961136p3158134.html
Sent from the Solr - User mailing list archive at Nabble.com.