18

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?

1 Answer 1

31

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
                }
            }
        }
    }}},
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.