Re: Need solr query help

2013-05-13 Thread smsolr
Hi Abhishek,

I forgot to explain why it works.  It uses the frange filter which is
mentioned here:-

http://wiki.apache.org/solr/CommonQueryParameters

and it works because it filters in results where the geodist minus the
shopMaxDeliveryDistance is less than zero (that's what the u=0 means, upper
limit=0), i.e.:-

geodist - shopMaxDeliveryDistance < 0
->
geodist < shopMaxDeliveryDistance

i.e. the geodist is less than the shopMaxDeliveryDistance and so the shop is
within delivery range of the location specified.

smsolr



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Need-solr-query-help-tp4061800p4062603.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Need solr query help

2013-05-13 Thread smsolr
Hi Abhishek,

I've had a look into this problem and have come up with a solution.

Following instructions assume you have downloaded the 4.3.0 release of Solr
from:-

http://www.apache.org/dyn/closer.cgi/lucene/solr/4.3.0

First add to:-

solr-4.3.0/solr/example/solr/collection1/conf/schema.xml

the following:-

   
   

after the id field:-



Then start solr by going to:-

solr-4.3.0/solr/example

and running:-

java -jar start.jar

Then change into your solr-4.3.0/solr/example/exampledocs directory and
write the following text to a new file called shops.xml:-



2468
Shop A
   0.1,0.1
   10


2469
Shop B
   0.2,0.2
   35


2470
Shop C
   0.9,0.1
   25


2480
Shop D
   0.3,0.2
   50




Now run:-

./post.sh shops.xml 

You should get back something like:-


Posting file shops.xml to http://localhost:8983/solr/update


0120




046



The doing the following queries in your browser:-

All 4 shops:-

http://localhost:8983/solr/select?q=name:shop&fl=name,shopLocation,shopMaxDeliveryDistance


All shops with distance from point 0.0,0.0 and ordered by distance from
point 0.0,0.0 (gives order A, B, D, C):-

http://localhost:8983/solr/select?q=name:shop&fl=name,shopLocation,shopMaxDeliveryDistance,geodist%28shopLocation,0.0,0.0%29&sort=geodist%28shopLocation,0.0,0.0%29%20asc


All shops with distance from point 0.0,0.0 and ordered by distance from
point 0.0,0.0 and filtered to eliminate all shops with distance from point
0.0,0.0 greater than shopMaxDeliveryDistance (gives shops  B and D):-

http://localhost:8983/solr/select?q=name:shop&fl=name,shopLocation,shopMaxDeliveryDistance,geodist%28shopLocation,0.0,0.0%29&sort=geodist%28shopLocation,0.0,0.0%29%20asc&fq={!frange%20u=0}sub%28geodist%28shopLocation,0.0,0.0%29,shopMaxDeliveryDistance%29


To delete all shops so you can edit the file to play with it and repost the
shops:-

http://localhost:8983/solr/update?stream.body=name:shop&commit=true



smsolr



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Need-solr-query-help-tp4061800p4062591.html
Sent from the Solr - User mailing list archive at Nabble.com.