Re: SOLR4 Spatial sorting and query string

2013-08-19 Thread David Smiley (@MITRE.org)
This is a known limitation.  From CHANGES.txt:
* SOLR-2345: Enhanced geodist() to work with an RPT field, provided that the
  field is referenced via 'sfield' and the query point is constant.
  (David Smiley)

The reason why that limitation is there relates to the fact that the
function query parser will attempt to resolve the field name if it's
referenced as an argument, and that'll fail because you can't get a
ValueSource from an RPT field because a ValueSource is a single-valued
construct and RPT isn't limited in that way

~ David


Billnbell wrote
> David,
> 
> We noticed in 4.5 that "sort=geodist(store_geohash) asc" does not work
> anymore. It works only if we: "sfield=store_geohash&sort=geodist() asc"
> 
> Thanks.





-
 Author: http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
--
View this message in context: 
http://lucene.472066.n3.nabble.com/SOLR4-Spatial-sorting-and-query-string-tp4084318p4085587.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: SOLR4 Spatial sorting and query string

2013-08-17 Thread William Bell
David,

We noticed in 4.5 that "sort=geodist(store_geohash) asc" does not work
anymore. It works only if we: "sfield=store_geohash&sort=geodist() asc"

Thanks.


On Thu, Aug 15, 2013 at 9:10 AM, David Smiley (@MITRE.org) <
dsmi...@mitre.org> wrote:

> Hi Roy,
>
> You'll have to calculate this client-side.  I am aware of this conundrum
> and
> I put up a TODO JIRA item for it here months ago:
> https://issues.apache.org/jira/browse/SOLR-4633It actually shouldn't
> be
> that hard to do.
>
> ~ David
>
>
> roySolr wrote
> > Hello David,
> >
> > The first months there will be not that many points in a doc, i will keep
> > the topic in mind!
> >
> > The next step is that i want to now which location matched my query.
> > Example:
> >
> > Product A is available in 3 stores, the doc looks like this:
> /
> > 
> > 
> > Product A
> > 
> > 
> >
> > 
> > store1_geo
> > 
> >
> > 
> > store2_geo
> > 
> >
> > 
> > store3_geo
> > 
> > 
> > 
> > 
> > London#store1_geo
> > 
> > 
> > Amsterdam#store2_geo
> > 
> > 
> > New York#store3_geo
> > 
> > 
> > 
> /
> >
> > I query the index with my location set to Berlin and a radius of 250km. I
> > know that this result gets back on the first place because it's close to
> > Amsterdam(store2_geo). But normally, How can i know which one matched my
> > query as closest point? Is it possible to get this back? I can do it in
> my
> > application but with 200 stores in a doc i don't think it's the best
> > solution.
> >
> > Thanks,
> >
> > Roy
>
>
>
>
>
> -
>  Author:
> http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/SOLR4-Spatial-sorting-and-query-string-tp4084318p4084816.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
Bill Bell
billnb...@gmail.com
cell 720-256-8076


Re: SOLR4 Spatial sorting and query string

2013-08-15 Thread David Smiley (@MITRE.org)
Hi Roy,

You'll have to calculate this client-side.  I am aware of this conundrum and
I put up a TODO JIRA item for it here months ago: 
https://issues.apache.org/jira/browse/SOLR-4633It actually shouldn't be
that hard to do.

~ David


roySolr wrote
> Hello David,
> 
> The first months there will be not that many points in a doc, i will keep
> the topic in mind!
> 
> The next step is that i want to now which location matched my query.
> Example:
> 
> Product A is available in 3 stores, the doc looks like this:
/
> 
> 
> Product A
> 
> 
>   
> 
> store1_geo
> 
>   
> 
> store2_geo
> 
>   
> 
> store3_geo
> 
> 
> 
> 
> London#store1_geo
> 
> 
> Amsterdam#store2_geo
> 
> 
> New York#store3_geo
> 
> 
> 
/
> 
> I query the index with my location set to Berlin and a radius of 250km. I
> know that this result gets back on the first place because it's close to
> Amsterdam(store2_geo). But normally, How can i know which one matched my
> query as closest point? Is it possible to get this back? I can do it in my
> application but with 200 stores in a doc i don't think it's the best
> solution.
> 
> Thanks,
> 
> Roy





-
 Author: http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
--
View this message in context: 
http://lucene.472066.n3.nabble.com/SOLR4-Spatial-sorting-and-query-string-tp4084318p4084816.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: SOLR4 Spatial sorting and query string

2013-08-15 Thread roySolr
Hello David,

The first months there will be not that many points in a doc, i will keep
the topic in mind!

The next step is that i want to now which location matched my query.
Example:

Product A is available in 3 stores, the doc looks like this:

/
Product A

  store1_geo
  store2_geo
  store3_geo


London#store1_geo
Amsterdam#store2_geo
New York#store3_geo

/

I query the index with my location set to Berlin and a radius of 250km. I
know that this result gets back on the first place because it's close to
Amsterdam(store2_geo). But normally, How can i know which one matched my
query as closest point? Is it possible to get this back? I can do it in my
application but with 200 stores i don't think it's the best solution.

Thanks,

Roy



--
View this message in context: 
http://lucene.472066.n3.nabble.com/SOLR4-Spatial-sorting-and-query-string-tp4084318p4084795.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: SOLR4 Spatial sorting and query string

2013-08-14 Thread Smiley, David W.
Roy,

How fast/slow this is is dependent on the total number of points in
documents that match the search results.  If one of those documents has
1000 points but most have a handful then it isn't such a big deal.  The
bigger problem is: https://issues.apache.org/jira/browse/LUCENE-4698

~ David

On 8/14/13 6:45 AM, "roySolr"  wrote:

>Hello,
>
>I have a question about performance with a lot of points and spatial
>search.
>First i will explain my situation:
>
>We have some products data and want to store every geo location of stores
>that sells this product.
>I use a multivalued coordinates field with the geo data:
>
>
> lat,long
> lat,long
> lat,long
> lat,long
> lat,long
>
>
>The config:
>
>*stored="true" multiValued="true"/>
>
>class="solr.SpatialRecursivePrefixTreeFieldType" distErrPct="0.025"
>maxDistErr="0.09" units="degrees"/>*
>
>When i search for a product term i want only the products that are nearby
>the given location. So i used to following query:
>
>fq=_query_:"{!geofilt sfield=store_coordinates pt=locatonlat,locationlong
>d=25}" 
>
>It works great but my question is: Will it work quick and smooth with
>+1000
>stores in my store_coordinates field?
>
>Any help is appreciated
>Thanks,
>
>Roy
>
>
>
>--
>View this message in context:
>http://lucene.472066.n3.nabble.com/SOLR4-Spatial-sorting-and-query-string-
>tp4084318p4084521.html
>Sent from the Solr - User mailing list archive at Nabble.com.



Re: SOLR4 Spatial sorting and query string

2013-08-14 Thread roySolr
Hello,

I have a question about performance with a lot of points and spatial search.
First i will explain my situation:

We have some products data and want to store every geo location of stores
that sells this product.
I use a multivalued coordinates field with the geo data:


 lat,long
 lat,long
 lat,long
 lat,long 
 lat,long


The config:

*

*

When i search for a product term i want only the products that are nearby
the given location. So i used to following query:

fq=_query_:"{!geofilt sfield=store_coordinates pt=locatonlat,locationlong
d=25}" 

It works great but my question is: Will it work quick and smooth with +1000
stores in my store_coordinates field?

Any help is appreciated
Thanks,

Roy



--
View this message in context: 
http://lucene.472066.n3.nabble.com/SOLR4-Spatial-sorting-and-query-string-tp4084318p4084521.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: SOLR4 Spatial sorting and query string

2013-08-14 Thread roySolr
Great, it works very well. In solr 4.5 i will use geodist() again!

Thanks David



--
View this message in context: 
http://lucene.472066.n3.nabble.com/SOLR4-Spatial-sorting-and-query-string-tp4084318p4084487.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: SOLR4 Spatial sorting and query string

2013-08-13 Thread David Smiley (@MITRE.org)
Hi Roy.

Using the example schema and data, and copying the "store" field to
"store_rpt" indexed with location_rpt field type, try this query:

http://localhost:8983/solr/select?indent=true&fl=name,store&q=*:*&sort=query%28{!geofilt%20score=distance%20filter=false%20sfield=store_rpt%20pt=45.15,-93.85%20d=0%20v=%27%27}%29%20asc

sort spec without url encoding:  query({!geofilt score=distance filter=false
sfield=store_rpt d=0 v=''}) asc

One of the tricks there is that it's sorting on the query() function query,
which references a query that has its score used as the result of query(). 
And you put a spatial query in there (note: score=distance only works with
rpt), and voila.  The fact that v='' is needed appears to be a Solr bug.  I
realize this is super awkward, so this approach isn't well documented if at
all.  In Solr 4.5 you can simply use geodist().

Note: if you have only one point per document, I recommend sorting by
LatLonType.

~ David


roySolr wrote
> Hello,
> 
> I use the following distance sorting of SOLR
> 4(solr.SpatialRecursivePrefixTreeFieldType):
> 
> fl=*,score&sort=score asc&q={!geofilt score=distance filter=false
> sfield=coords pt=54.729696,-98.525391 d=10}  
> 
> (from the tutorial on
> http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4)
> 
> Now i want to query on a searchstring and still want to sort on distance.
> How can i combine this in above solr request? When i add something to the
> "q=" it doesn't work. I tried _query_ subquery and other stuff but i don't
> get it working
> 
> I appreciate any help,
> Thanks





-
 Author: http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
--
View this message in context: 
http://lucene.472066.n3.nabble.com/SOLR4-Spatial-sorting-and-query-string-tp4084318p4084453.html
Sent from the Solr - User mailing list archive at Nabble.com.


SOLR4 Spatial sorting and query string

2013-08-13 Thread roySolr
Hello,

I use the following distance sorting of SOLR
4(solr.SpatialRecursivePrefixTreeFieldType):

fl=*,score&sort=score asc&q={!geofilt score=distance filter=false
sfield=coords pt=54.729696,-98.525391 d=10}  

(from the tutorial on
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4)

Now i want to query on a searchstring and still want to sort on distance.
How can i combine this in above solr request? When i add something to the
"q=" it doesn't work. I tried _query_ subquery and other stuff but i don't
get it working

I appreciate any help,
Thanks



--
View this message in context: 
http://lucene.472066.n3.nabble.com/SOLR4-Spatial-sorting-and-query-string-tp4084318.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: geodist() spatial sorting: sort param could not be parsed as a query, and is not a field that exists in the index: geodist()

2013-02-28 Thread PeterKerk
You were right, sloppy on my side. I replaced the %20 with & (in more than 1
place) and now it does work. Thanks.



--
View this message in context: 
http://lucene.472066.n3.nabble.com/geodist-spatial-sorting-sort-param-could-not-be-parsed-as-a-query-and-is-not-a-field-that-exists-in--tp4043603p4043686.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: geodist() spatial sorting: sort param could not be parsed as a query, and is not a field that exists in the index: geodist()

2013-02-28 Thread David Smiley (@MITRE.org)
Strange.  The code in Solr that has that error string passes an an additional
exception that will have its own error message that is more detailed, and
you'll see that in the stack trace in the Solr logs; perhaps in your error
response too but I'm not sure.

If you remove the sorting, are the search results otherwise right?  I'm
looking at your query and some things look wrong.  Notably, where you refer
to "sfield", this is either supposed to be a request parameter or
local-param but you've concatenated it with the point that preceded with an
adjoining space (%20).  Use an ampersand in place of that %20 and see if it
starts working.

~ David


PeterKerk wrote
> I want to sort the results of my query on distance.
> 
> But I get this error:
> sort param could not be parsed as a query, and is not a field that exists
> in the index: geodist()
> 
> On this query:
> 
> http://localhost:8983/solr/tt/select/?indent=on&facet=true&fq=countryid:1&fq={!geofilt}&pt=51.8425,5.85278%20sfield=geolocation%20d=20&q=*:*&start=0&rows=10&fl=id,title,city&facet.mincount=1&sort=geodist()%20asc
> 
> I also tried:
> http://localhost:8983/solr/tt/select/?indent=on&facet=true&fq=countryid:1&fq={!geofilt&pt=51.8425,5.85278%20sfield=geolocation%20d=20}&q=*:*&start=0&rows=10&fl=id,title,city&facet.mincount=1&sort=geodist()%20asc
> 
> Here's what I have in my schema.xml:
>  subFieldSuffix="_coordinate"/>
>   
> 
> 
>  stored="false"/>
> I've been checking this page: http://wiki.apache.org/solr/SpatialSearch
> But that does not mention my error.





-
 Author: http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
--
View this message in context: 
http://lucene.472066.n3.nabble.com/geodist-spatial-sorting-sort-param-could-not-be-parsed-as-a-query-and-is-not-a-field-that-exists-in--tp4043603p4043679.html
Sent from the Solr - User mailing list archive at Nabble.com.


geodist() spatial sorting: sort param could not be parsed as a query, and is not a field that exists in the index: geodist()

2013-02-28 Thread PeterKerk
I want to sort the results of my query on distance.

But I get this error:
sort param could not be parsed as a query, and is not a field that exists in
the index: geodist()

On this query:

http://localhost:8983/solr/tt/select/?indent=on&facet=true&fq=countryid:1&fq={!geofilt}&pt=51.8425,5.85278%20sfield=geolocation%20d=20&q=*:*&start=0&rows=10&fl=id,title,city&facet.mincount=1&sort=geodist()%20asc

I also tried:
http://localhost:8983/solr/tt/select/?indent=on&facet=true&fq=countryid:1&fq={!geofilt&pt=51.8425,5.85278%20sfield=geolocation%20d=20}&q=*:*&start=0&rows=10&fl=id,title,city&facet.mincount=1&sort=geodist()%20asc

Here's what I have in my schema.xml:

  





I've been checking this page: http://wiki.apache.org/solr/SpatialSearch
But that does not mention my error.



--
View this message in context: 
http://lucene.472066.n3.nabble.com/geodist-spatial-sorting-sort-param-could-not-be-parsed-as-a-query-and-is-not-a-field-that-exists-in--tp4043603.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: spatial sorting

2010-09-30 Thread dan sutton
Hi All,

This is more of an FYI for those wanting to filter and sort by distance, and
have the values returned in the result set after determining a way to do
this with existing code.

Using solr 4.0 an example query would contain the following parameters:

/select?

q=stevenage^0.0
+_val_:"ghhsin(6371,geohash(52.0274,-0.4952),location)"^1.0

Make the boost on all parts of the query other than the ghhsin distance
value function 0 ,and 1 on the function, this is so that the score is then
equal to the distance. (52.0274,-0.4952) here is the query point and
'location' is the geohash field to search against



sort=score asc

basically sort by distance asc (closest first)



fq={!sfilt%20fl=location}&pt=52.0274,-0.4952&d=30

This is the spatial filter to limit the necessary distance calculations.



fl=*,score

Return all fields (if required) but include the score (which contains the
distance calculation)


Does anyone know if it's possible to return the distance and score
separately?  I know there has been a patch to sort by value function, but
how can one return the values from this?

Cheers,
Dan


On Fri, Sep 17, 2010 at 2:45 PM, dan sutton  wrote:

> Hi,
>
> I'm trying to filter and sort by distance with this URL:
>
>
> http://localhost:8080/solr/select/?q=*:*&fq={!sfilt%20fl=loc_lat_lon}&pt=52.02694,-0.49567&d=2&sort={!func}hsin(52.02694,-0.49567,loc_lat_lon_0_d,%20loc_lat_lon_1_d,3963.205)asc
>
> Filtering is fine but it's failing in parsing the sort with :
>
> "The request sent by the client was syntactically incorrect (can not sort
> on undefined field or function: {!func}(52.02694,-0.49567,loc_lat_lon_0_d,
> loc_lat_lon_1_d, 3963.205))."*
>
> *I'm using the solr/lucene trunk to try this out ... does anyone know what
> is wrong with the syntax?
>
> Additionally am I able to return the distance sort values e.g. with param
> fl ? ... else am I going to have to either write my own component (which
> would also look up the filtered cached values rather than re-calculating
> distance) or use an alternative like localsolr ?
>
> Dan
>


Re: spatial sorting

2010-09-21 Thread Grant Ingersoll

On Sep 17, 2010, at 9:45 AM, dan sutton wrote:

> Hi,
> 
> I'm trying to filter and sort by distance with this URL:
> 
> http://localhost:8080/solr/select/?q=*:*&fq={!sfilt%20fl=loc_lat_lon}&pt=52.02694,-0.49567&d=2&sort={!func}hsin(52.02694,-0.49567,loc_lat_lon_0_d,%20loc_lat_lon_1_d,3963.205)asc
> 
> Filtering is fine but it's failing in parsing the sort with :
> 
> "The request sent by the client was syntactically incorrect (can not sort on
> undefined field or function: {!func}(52.02694,-0.49567,loc_lat_lon_0_d,
> loc_lat_lon_1_d, 3963.205))."*

I don't see a function declared in that line, although it is in the one above.  
Also, you need a space between the function and asc.

spatial sorting

2010-09-17 Thread dan sutton
Hi,

I'm trying to filter and sort by distance with this URL:

http://localhost:8080/solr/select/?q=*:*&fq={!sfilt%20fl=loc_lat_lon}&pt=52.02694,-0.49567&d=2&sort={!func}hsin(52.02694,-0.49567,loc_lat_lon_0_d,%20loc_lat_lon_1_d,3963.205)asc

Filtering is fine but it's failing in parsing the sort with :

"The request sent by the client was syntactically incorrect (can not sort on
undefined field or function: {!func}(52.02694,-0.49567,loc_lat_lon_0_d,
loc_lat_lon_1_d, 3963.205))."*

*I'm using the solr/lucene trunk to try this out ... does anyone know what
is wrong with the syntax?

Additionally am I able to return the distance sort values e.g. with param fl
? ... else am I going to have to either write my own component (which would
also look up the filtered cached values rather than re-calculating distance)
or use an alternative like localsolr ?

Dan