Re: Need solr query help

2013-05-14 Thread Amit Nithian
Is it possible instead to store in your solr index a bounding box of store
location + delivery radius, do a bounding box intersection between your
user's point + radius (as a bounding box) and the shop's delivery bounding
box. If you want further precision, the frange may work assuming it's a
post-filter implementation so that you are doing heavy computation on a
presumably small set of data only to filter out the corner cases around the
radius circle that results.

I haven't looked at Solr's spatial querying in a while to know if this is
possible or not.

Cheers
Amit


On Sat, May 11, 2013 at 10:42 AM, smsolr sms...@hotmail.com wrote:

 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:-

   field name=shopLocation type=location indexed=true stored=true/
   field name=shopMaxDeliveryDistance type=float indexed=true
stored=true/

after the id field:-

   field name=id type=string indexed=true stored=true
required=true multiValued=false / 

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:-

add
doc
field name=id2468/field
field name=nameShop A/field
   field name=shopLocation0.1,0.1/field
   field name=shopMaxDeliveryDistance10/field
/doc
doc
field name=id2469/field
field name=nameShop B/field
   field name=shopLocation0.2,0.2/field
   field name=shopMaxDeliveryDistance35/field
/doc
doc
field name=id2470/field
field name=nameShop C/field
   field name=shopLocation0.9,0.1/field
   field name=shopMaxDeliveryDistance25/field
/doc
doc
field name=id2480/field
field name=nameShop D/field
   field name=shopLocation0.3,0.2/field
   field name=shopMaxDeliveryDistance50/field
/doc
/add


Now run:-

./post.sh shops.xml 

You should get back something like:-


Posting file shops.xml to http://localhost:8983/solr/update
?xml version=1.0 encoding=UTF-8?
response
lst name=responseHeaderint name=status0/intint
name=QTime120/int/lst
/response

?xml version=1.0 encoding=UTF-8?
response
lst name=responseHeaderint name=status0/intint
name=QTime46/int/lst
/response


The doing the following queries in your browser:-

All 4 shops:-

http://localhost:8983/solr/select?q=name:shopfl=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:shopfl=name,shopLocation,shopMaxDeliveryDistance,geodist%28shopLocation,0.0,0.0%29sort=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:shopfl=name,shopLocation,shopMaxDeliveryDistance,geodist%28shopLocation,0.0,0.0%29sort=geodist%28shopLocation,0.0,0.0%29%20ascfq={!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=deletequeryname:shop/query/deletecommit=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.


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.


Need solr query help

2013-05-09 Thread Abhishek tiwari
We are doing spatial search. with following logic.
a) There are shops in a city . Each provides the facility of home delivery
b) each shop has different  max_delivery_distance .

Now my query is suppose some one is searching from point P1 with radius R.

User wants the result of shops those can deliver him.(distance between P1
to shop s1 say d1 should be less than max_delivery distance say md1 )

how can i implement this by solr spatial query.