What is the difference between a filter clause in a query or a filter

I have these two queries

First

GET propertywebsites3/_search
{
  "_source": "city", 
  "query": {
    "bool": {
      "filter": {
        "term": {
          "city.raw": "Dubai"
        }
      }
    }
  }
}

Seond

GET propertywebsites3/_search
{
  "_source": "city", 
  "query": {
    "filtered": {
      "filter": {
        "term": {
          "city.raw": "Dubai"
        }
      }
    }
  }
}

The first one gives 0 for all the scores, I see that in this page https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html it is written that if you use the filter clause in a bool clause, all matching documents will have 0 in the score,

and the second query gives 1 to the score of all the documents.

first of all why not both of them either 0 or 1. second aren't they supposed to do they same? which is filtering all the documents that its city is "Dubai" ?

thanks

Filtered query has been deprecated. See https://www.elastic.co/guide/en/elasticsearch/reference/2.2/query-dsl-filtered-query.html

If you add a match_all query in the must clause of the bool query, what is the score?

Thanks for your reply.

If I add a match_all, the score becomes all 1 instead of 0.

So if I understood you correctly, whenever i want to do a filter now, I should use a bool clause with a filter clause inside , right please?

right!

So the reason with the difference between the score is that the filtered query actually adds a match_all query which set the _score to 1 for each document and the bool query does not add a query.