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
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.*/"
}
}
]
}
}
}
**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)