# Field analyzer ignored on query string regex - 7.10.2

**URL:** https://discuss.elastic.co/t/field-analyzer-ignored-on-query-string-regex-7-10-2/271375
**Category:** Elasticsearch
**Created:** [April 27, 2021, 12:45pm UTC](https://discuss.elastic.co/t/field-analyzer-ignored-on-query-string-regex-7-10-2/271375 "2021-04-27T12:45:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![korali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/korali/32/82834_2.png) [@korali](https://discuss.elastic.co/u/korali)
#### Post date: [April 27, 2021, 12:45pm UTC](https://discuss.elastic.co/t/field-analyzer-ignored-on-query-string-regex-7-10-2/271375/1 "2021-04-27T12:45:39Z")

</div>

Hey, I search with query of type query\_string with regex and when I try to run the same code in elasticsearch 7.1.1 and elasticsearch 7.10.2 I get different results

Index Mapping&Settings

```auto
        PUT index_name
        {
          "settings": {
            "index": {
              "analysis": {
                "filter": {
                  "truncateString": {
                    "length": "5",
                    "type": "truncate"
                  }
                },
                "analyzer": {
                  "stringTruncate": {
                    "filter": [
                      "trim",
                      "lowercase",
                      "truncateString"
                    ],
                    "tokenizer": "keyword"
                  }
                }
              }
            }
          },
          "mappings": {
            "properties": {
              "message": {
                "analyzer": "stringTruncate",
                "type": "text"
              }
            }
          }
        }
 
    POST index_name/_doc
    {
      "message":"Koooooo"
    }

```

```
    GET index_name/_search
    {
    	"query": {
    		"bool": {
    			"must": [
    				{
    					"query_string": {
    						"query": "message:/K.*/"
    					}
    				}
    			]
    		}
    	}
    }

```

```auto
**The results of search elasticsearch 7.10.1** 
    {
        "took": 1,
        "timed_out": false,
        "_shards": {
            "total": 3,
            "successful": 3,
            "skipped": 0,
            "failed": 0
        },
        "hits": {
            "total": {
                "value": 0,
                "relation": "eq"
            },
            "max_score": null,
            "hits": []
        }
    }
**The results of search elasticsearch 7.1.1** 
run the same code in elasticsearch 7.1.1 return the expected results
     "hits" : [
          {
            "_index" : "index_name",
            "_type" : "_doc",
            "_id" : "kS40E3kB8MTOQatKQ5Qq",
            "_score" : 1.0,
            "_source" : {
              "message" : "Koooooo"
            }
          }
    ]
If I specify the analyzer in the query in elasticsearch 7.10.2
I would get the expected results : 
        GET index_name/_search
            {
            	"query": {
            		"bool": {
            			"must": [
            				{
            					"query_string": {
            						"query": "message:/K.*/",
                                                            "analyzer":"stringTruncate"
            					}
            				}
            			]
            		}
            	}
            }
        "hits" : [
              {
                "_index" : "index_name",
                "_type" : "_doc",
                "_id" : "GZwyE3kBEzq5gZ4c13_N",
                "_score" : 1.0,
                "_source" : {
                  "message" : "Koooooo"
                }
              }

```

It looks like the elastic does not recognize the analyzer at the time of query in elastic version 7.10.2  
(It's also not working with the standard\_analyzer)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 25, 2021, 12:46pm UTC](https://discuss.elastic.co/t/field-analyzer-ignored-on-query-string-regex-7-10-2/271375/2 "2021-05-25T12:46:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
