Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown key for a START_OBJECT in [bool] in elastic search

Elasticsearch is giving this error like Unknown key for a START_OBJECT in [bool] in Elasticsearch.

My query is as below: Updated

var searchParams = {
  index: 'offers',
  body:{
    query:{
    bool : {
      must : {
        query: {
            multi_match: {
                  query: query,
                  fields:['title','subTitle','address','description','tags','shopName'],
                  fuzziness : 'AUTO'
            }
        }
      },
      filter : {
            geo_distance : {
                distance : radius,
                location : {
                    lat : latitude,
                    lon : longitude
                }
            }
        }
    }}},
  filter_path :'hits.hits._source',
  pretty:'true'
};

Can anyone tell me how to mix this both geo and fuzzy search query in elastic search?

like image 673
dkp1997 Avatar asked Dec 12 '17 13:12

dkp1997


1 Answers

The body should look like this (you're missing the query section):

  body:{
   query: {        <--- add this
    bool : {
      must : {
          multi_match: {
                query: query,
                fields:['title','subTitle','address','description','tags','shopName'],
                fuzziness : 'AUTO'
          }
      },
      filter : {
            geo_distance : {
                distance : radius,
                location : {
                    lat : latitude,
                    lon : longitude
                }
            }
        }
    }}},
like image 82
Val Avatar answered Nov 06 '22 10:11

Val