Nearby Query with Dynamic Data

(Nearby Query)

We are building a search engine where user will type like

  1. Restaurant (Category) in Delhi (place)

  2. Bar (Category) in Mumbai (place)

We are supposed to search first tag into category and second tag into place.

So the final query would be something like

First we need to get the Lat, Long from places and then make the second query as a nearby from lat long.

"query": "hotel",
"search_fields": {
"category": {}
},
"result_fields": {
"category": {
"raw": {}
},
"name": {
"raw": {}

},
"filters": {
    "location": { // our field key 
        "center": [
             (lat, Long) ( this should be dynamic coming from another query. A match with places)  
        ],
        "distance": 15,
        "unit": "km"
    }

If you pull the lat, long out, then pass it into the query in your code it'll work. Otherwise Elasticsearch cannot merge things that way, no.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.