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 martin_groenhof <ma...@yahoo.com> on 2011/05/19 14:52:03 UTC
Spatial search with SolrJ 3.1 ? How to
How do you construct a query in java for spatial search ? not the default
solr REST interface
--
View this message in context: http://lucene.472066.n3.nabble.com/Spatial-search-with-SolrJ-3-1-How-to-tp2961136p2961136.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>.
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.
SolrJ & Spatial Search
Posted by SR <r....@gmail.com>.
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: Spatial search with SolrJ 3.1 ? How to
Posted by martin_groenhof <ma...@yahoo.com>.
I don't care about the method, I just want results within let's say 10km of a
lat,lng ?
(I can do this with REST) but don't know how to with a Java API
[code] SpatialOptions spatialOptions =
new SpatialOptions(company.getLatitude() + "," +
company.getLongitude(),
10, new SchemaField("geolocation", null), searchName, 20,
DistanceUnits.KILOMETERS);
LatLonType latLonType = new LatLonType();
Query query = latLonType.createSpatialQuery(new
SpatialFilterQParser(searchString.toString(), solrq, solrq, null, true),
spatialOptions);[/code]
(I am trying with this, but it does not seem to be compatible with solr only
lucene)
Any example will do, Thx
--
View this message in context: http://lucene.472066.n3.nabble.com/Spatial-search-with-SolrJ-3-1-How-to-tp2961136p2961452.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Spatial search with SolrJ 3.1 ? How to
Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Thu, May 19, 2011 at 8:52 AM, martin_groenhof
<ma...@yahoo.com> wrote:
> How do you construct a query in java for spatial search ? not the default
> solr REST interface
It depends on what you are trying to do - a spatial request (as
currently implemented in Solr) is typically more than just a query...
it can be filtering by a bounding box, filtering by a distance radius,
or using a distance (geodist) function query in another way such as
sorting by it or using it as a factor in relevance.
-Yonik
http://www.lucenerevolution.org -- Lucene/Solr User Conference, May
25-26, San Francisco