elasticsearchHow can I perform a case-insensitive wildcard search using Elasticsearch?
A wildcard search in Elasticsearch using a case-insensitive query is possible by using the lowercase_expanded_terms parameter.
Example code
GET /my_index/_search
{
"query": {
"wildcard": {
"my_field": {
"value": "*test*",
"lowercase_expanded_terms": false
}
}
}
}
This query will return all documents that contain the term test in the my_field field, regardless of the case.
The lowercase_expanded_terms parameter is set to false by default, so it is not necessary to set it explicitly.
Code explanation
GET /my_index/_search- the endpoint used to send the query to Elasticsearch"query": { "wildcard": { "my_field": { "value": "*test*"- thewildcardquery used to perform the search, withmy_fieldas the field to search in and*test*as the value to search for"lowercase_expanded_terms": false- the parameter used to make the search case-insensitive
Helpful links
More of Elasticsearch
- How can I use Elasticsearch with Zammad?
- How can I use YouTube to learn about Elasticsearch?
- How do I set up an Elasticsearch Yum repository?
- How do I use Yandex with Elasticsearch?
- How can I use X-Pack Security with Elasticsearch?
- How can I use Elasticsearch to diagnose "yellow" issues?
- How can I use Elasticsearch in Russia?
- How do I configure Elasticsearch to work with PostgreSQL?
- How can I set up and use Elasticsearch on the Yandex Cloud platform?
- How do I configure Elasticsearch with a YML file?
See more codes...