Search code examples
lucenesolrj

solr geodist() giving wrong distance


I am using geodist() in solr query. following is my query

q=(name:(*)&fl=person_id, name, longitude, lattitude, distance:geodist()&fq={!geofilt}&spatial=true&pt=73.7708441,18.5664871&d=10&sort=geodist() asc&group=true&group.field=person_id&group.format=simple&group.main=true&start=0&rows=15

one of entry in my output is

{
    \"personId\": 313403,
    \"name\": \"Dev\",
    \"longitude\": 73.812498,
    \"latitude\": 18.439598,
    \"distance\": 6.079763395151475,
}

But when I count distance between both lat long on internet i.e (73.7708441,18.5664871) to (73.812498, 18.439598), It gives me 14.782 km or 9.187 in mile

I searched about solr geodist() but same function and query is used everywhere. Can somebody please tell me whats going wrong here?


Solution

  • Finally resolved.

    There were too mistake

    1-pt should be pt=lat, long

    2-while putting lat long in solr (by data-config.xml), name of latitude field should be location_0_coordinate and longitude - location_1_coordinate

    in my case it was interchanged