# Elasticsearch Query function\_score ignores quotes in query string

**URL:** <https://discuss.elastic.co/t/elasticsearch-query-function-score-ignores-quotes-in-query-string/356877>\
**Category:** Elasticsearch\
**Created:** [April 5, 2024, 2:22pm UTC](https://discuss.elastic.co/t/elasticsearch-query-function-score-ignores-quotes-in-query-string/356877 "2024-04-05T14:22:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Savo\_Pejovic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/savo_pejovic/32/133310_2.png) [@Savo\_Pejovic](https://discuss.elastic.co/u/Savo_Pejovic)\
**Post date:** [April 5, 2024, 2:22pm UTC](https://discuss.elastic.co/t/elasticsearch-query-function-score-ignores-quotes-in-query-string/356877/1 "2024-04-05T14:22:27Z")

</div>

The results of two same query string queries with quoted phrases return different results if one query is wrapped inside a `function_score` query. In the wrapped query, the phrase isn't preserved in full but tokenized, which can be seen by the highlighted results.

**QueryA** :

```json
GET consolidated-index991/_search
{
  "from": 0,
  "highlight": {
    "fields": {
      "content": {}
    },
    "max_analyzed_offset": 999999,
    "number_of_fragments": 5
  },
  "query": {
    "function_score": {
      "query": {
        "query_string": {
          "analyzer": "cg_analyzer_naziv",
          "fields": [
            "content"
          ],
          "query": "\"savo pejovic\"",
          "boost": 3
        }
      }
    }
  },
  "size": 10,
  "sort": [
    {
      "_score": {
        "order": "desc"
      }
    }
  ],
  "_source": {
    "includes": [
      "genericReference",
      "isActive"
    ]
  }
}

```

**QueryB** :

```json
{
  "from": 0,
  "highlight": {
    "fields": {
      "content": {}
    },
    "max_analyzed_offset": 999999,
    "number_of_fragments": 5
  },
  "query": {
    "query_string": {
      "analyzer": "cg_analyzer_naziv",
      "fields": [
        "content"
      ],
      "query": "\"savo pejovic\"",
      "boost": 3
    }
  },
  "size": 10,
  "sort": [
    {
      "_score": {
        "order": "desc"
      }
    }
  ],
  "_source": {
    "includes": [
      "genericReference",
      "isActive"
    ]
  }
}

```

QueryA returns hits that highlight just one of these tokens, while QueryB only returns hits with exact phrase hihglighted.

How to make QueryA behave like QueryB?
