Ganesh Jadhav
Ganesh Jadhav

Reputation: 616

Solr multi core join with Spatial Search

I have two cores customer and location. Following is sample data of customer core

[{"Name":abc,"Id":123},{"Name":xyz,"Id"354}]

and following is sample data of location core

[{"locationid":9834,"customerId":123,"lat_long_loc_s_i":"53.258496, -0.757421","active":True},
 {"locationid":9834,"customerId":354,"lat_long_loc_s_i":"53.258496, -0.757421","active":True},....
]

I want to search for the customers, who are living in 10 miles radius and active location.

The following query will give me the list of customers who have an active location

http://xx.xx.xx.xx:8983/solr/customer/select?q=*:*&fq={!join%20from=customerId%20to=Id%20fromIndex=location}active:True

How can I add spatial search on location core with an active filter to this

d=10&indent=on&pt=51.480401,%20-0.110252&sfield=lat_long_loc_s_i

if I add "&d=10...", it will apply query on customer core instead of location core.

(Solr version 7.2)

Upvotes: 0

Views: 44

Answers (1)

Aman Tandon
Aman Tandon

Reputation: 1509

Please try as below, if this solves

I just used the *_p dynamic field for location, so modified the provided data.

Location data

enter image description here

Customer data

enter image description here

Joined data to filter records with d within 1000

enter image description here

Query:

http://localhost:8983/solr/customer/select?q=*:*&fq={!join%20from=customerId%20to=Id%20fromIndex=location}active:true%20AND%20{!geofilt%20sfield=lat_long_loc_p}%20AND%20locationid:9836&d=800&indent=on&pt=52,0.5&sfield=lat_long_loc_p&debug=query

Upvotes: 0

Related Questions