14

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?

Simulant
  • 19,190
  • 8
  • 63
  • 98
dkp1997
  • 175
  • 1
  • 2
  • 7

1 Answers1

27

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
                }
            }
        }
    }}},
Val
  • 207,596
  • 13
  • 358
  • 360