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 zone awareness to improve my software development?
- How do I use Elasticsearch with ZGC?
- How can I use Elasticsearch and ZFS together?
- How can I use Elasticsearch and Zabbix together for software development?
- How can I use Elasticsearch to diagnose "yellow" issues?
- How do I use ElasticSearch to zip files?
- How do I set up an Elasticsearch Yum repository?
- How can I check the status of a yellow index in Elasticsearch?
- How can I use YouTube to learn about Elasticsearch?
- How can I set up and use Elasticsearch on the Yandex Cloud platform?
See more codes...