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.