Sort by geo_distance where latitude and longitude given is 0.00 in ElasticSearch
Asked Answered
J

0

0

Here are two records:

Ryan Restaurant:

'location' => [ 'lat' => 72.1909090,  'lon' =>19.123456],
'name' => Ryan Restaurant,
'type' => 'restaurant'

Play Restaurant:

'location' => [ 'lat' => 72.1900010,  'lon' =>19.9645673],
'name' => Play Restaurant,
'type' => 'restaurant'

Ashita Singh:

'location' => [ 'lat' => 0.0000000,  'lon' =>0.000000],
'name' => Ashita Singh,
'type' => 'homemade'

How to display all the documents which have lat and long as 0.00 and documents which lie within 5km? Is it possible to not include some documents in sort?

Johnson answered 27/12, 2015 at 14:2 Comment(14)
your problem seems to be a little unclearInstanter
what is it that you exactly wantInstanter
@AnirudhModi I have edited my question. Have a look and let me know if you can help me. Thanks. I appreciate it.Johnson
I am trying to understand how would ES know if Ashita singh is within 5km and other homemade stuff is not?Aestival
@Aestival I am stuck at that only. Can't it filter out homemade from sorting and geo_distance filter?Johnson
you should try google geocoding service if you have address of homemade guys or you would have to return all homemade results but that does not make sense I guessAestival
problem is unclear. what is the expected output?Blench
have you tried using geo distance range filter?? The problem seems to still a little unclear... elastic.co/guide/en/elasticsearch/reference/1.4/… May be this can help you?Instanter
@SteveCasey I am looking to filter with geo_distance but homemade records should be included as latitude and longitude is 0.00. Let me know if it's still unclear.Johnson
@Johnson Does this mean you want all the documents which have lat and long as 0.00 and documents which are lie within 5km right?Instanter
Have you considered using geo distance range?Instanter
One solution will be using bool filter.. Your bool will have two should clause, one should clause will use the geo distance filter and set its value to 0.00 so that all the records which are 0.00 can be retrieved and the other should clause will be using the range geo distance,which can help you in getting the 5km range.Instanter
@AnirudhModi I thought about that initially, but then why do you want to give Mumbai's homemade result when user is searching in Delhi? Thats why I asked OP to use geocoding serviceAestival
@Aestival Ok. I dont know about geocoding, but what you say that is also tru..Instanter

© 2022 - 2024 — McMap. All rights reserved.