When you index some text, it gets analyzed by Elasticsearch.
Using the default analyzer:
POST _analyze
{
"text": [ "{\"kind\":\"user_test\",\"sts\":\"2020-04-23 10:26:29\",\"uc\":,\"rc\":\"ok\",\"errc\":0}" ]
}
Internally Elasticsearch will generate the tokens:
{
"tokens" : [
{
"token" : "kind",
"start_offset" : 2,
"end_offset" : 6,
"type" : "<ALPHANUM>",
"position" : 0
},
{
"token" : "user_test",
"start_offset" : 9,
"end_offset" : 18,
"type" : "<ALPHANUM>",
"position" : 1
},
{
"token" : "sts",
"start_offset" : 21,
"end_offset" : 24,
"type" : "<ALPHANUM>",
"position" : 2
},
{
"token" : "2020",
"start_offset" : 27,
"end_offset" : 31,
"type" : "<NUM>",
"position" : 3
},
{
"token" : "04",
"start_offset" : 32,
"end_offset" : 34,
"type" : "<NUM>",
"position" : 4
},
{
"token" : "23",
"start_offset" : 35,
"end_offset" : 37,
"type" : "<NUM>",
"position" : 5
},
{
"token" : "10",
"start_offset" : 38,
"end_offset" : 40,
"type" : "<NUM>",
"position" : 6
},
{
"token" : "26",
"start_offset" : 41,
"end_offset" : 43,
"type" : "<NUM>",
"position" : 7
},
{
"token" : "29",
"start_offset" : 44,
"end_offset" : 46,
"type" : "<NUM>",
"position" : 8
},
{
"token" : "uc",
"start_offset" : 49,
"end_offset" : 51,
"type" : "<ALPHANUM>",
"position" : 9
},
{
"token" : "rc",
"start_offset" : 55,
"end_offset" : 57,
"type" : "<ALPHANUM>",
"position" : 10
},
{
"token" : "ok",
"start_offset" : 60,
"end_offset" : 62,
"type" : "<ALPHANUM>",
"position" : 11
},
{
"token" : "errc",
"start_offset" : 65,
"end_offset" : 69,
"type" : "<ALPHANUM>",
"position" : 12
},
{
"token" : "0",
"start_offset" : 71,
"end_offset" : 72,
"type" : "<NUM>",
"position" : 13
}
]
}
Another search query might be quite equivalent:
GET crazytest/_search
{
"query": {
"query_string": {
"query": "kind AND user_test AND rc AND ok AND errc AND 0",
"default_field": "message"
}
}
}
If you really want to search for specific strings within the text, you should change the analyzer (but it will require reindexing) or try to query on the keyword field (if you have the same data but in a keyword
field), but it will be an heavy query as you will need to rely on leading wildcards or a regular expression.
Ref: