I am trying to implement lowercase functionality in ElasticSearch. According to their API docs here
https://www.elastic.co/guide/en/elasticsearch/reference/current/lowercase-processor.html
you use this code snippet
{
"lowercase": {
"field": "foo"
}
}
in the query to get a lowercase value contained in the required field.
They do not have a specific example and I keep getting an error when I execute a search query.
This is what I tried:
POST /users/_search
{
"size" : 10,
"_source" : {
"includes" : [
"userid",
"username"
]
},
"query" : {
"query_string" : {
"query" : "*John*",
"lowercase": { "default_field" : "username.keyword"}
}
},
"sort" : [
{
"_doc" : {
"order" : "desc"
}
}
]
}
In the above query I try to find a username 'john' (converted 'John' to lowercase).
Error message is as follows:
{
"error" : {
"root_cause" : [
{
"type" : "parsing_exception",
"reason" : "[query_string] unknown token [START_OBJECT] after
[lowercase]",
"line" : 18,
"col" : 27
}
],
"type" : "parsing_exception",
"reason" : "[query_string] unknown token [START_OBJECT] after
[lowercase]",
"line" : 18,
"col" : 27
},
"status" : 400
}
The same query works (although it does not give me the result that I need) if I replace
"lowercase": { "default_field" : "username.keyword"}
with
"default_field" : "username.keyword"
Any suggestions about how I can fix this query? Thanks!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…