Question: I'm in the process of upgrading from elasticsearch 1.7 to 6.7. One of the changes is the removal of filtered query in favor of a bool query.

I am looking for help to convert the below query.

I have tried to change "and" to "must" and "filtered" to "bool"

Here is the code:

```

{
    "size": 0,
    "_source": false,
    "query": {
        "filtered": {
            "filter": {
                "and": [{
                    "geo_distance": {
                        "distance": "50mi"
                        "location": "35.323312, -23.14848"
                    }
                },
                {
                    "bool": {
                        "must": {
                            "term": {
                                "id_from_store": 99
                            }
                        }
                    }
                },
                {
                    "bool": {
                        "must": {
                            "term": {
                                "is_new": 1
                            }
                        }
                    }
                },
                {
                    "bool": {
                        "must": {
                            "range": {
                                "datetime_shelf": {
                                    "gte": "2018-02-01"
                                }
                            }
                        }
                    }
                }]
            }
        }
    },
    "aggs": {
        "group_by_listing": {
            "terms": {
                "field": "p_id",
                "size": 200 
            }
        }
    }
}

```

How do I correctly structure this?

Answer: 
Simply like this:

```
{
  "size": 0,
  "_source": false,
  "query": {
    "bool": {
      "filter": [
        {
          "geo_distance": {
            "distance": "50mi",
            "location": "35.323312, -23.14848"
          }
        },
        {
          "term": {
            "id_from_store": 99
          }
        },
        {
          "term": {
            "is_new": false
          }
        },
        {
          "range": {
            "datetime_shelf": {
              "gte": "2018-02-01"
            }
          }
        }
      ]
    }
  },
  "aggs": {
    "group_by_listing": {
      "terms": {
        "field": "p_id",
        "size": 200
      }
    }
  }
}

```
Query should be structured like below. No need to add bool and must for each query

```
query" : {
    "bool" : {
      "must": [
                 {"geo_distance":<your_query>},
                 {"term":<your_query>},
                 {"term":<your_query>},
                 {"range":<your_query>}
              ]
             }
         }

```