opened 03:30PM - 23 May 24 UTC
>bug
needs:triage
### Elasticsearch Version
8.15.0
### Installed Plugins
_No response_
### Jav…a Version
_bundled_
### OS Version
Elastic Cloud
### Problem Description
Context in [Discuss forum post](https://discuss.elastic.co/t/term-query-with-empty-string-and-case-insensitive-setting-become-invalid/359961).
The `term` query on a keyword field with an empty value ("") behaves differently depending on the `case_insensitive` flag:
- If `case_insensitive==false` (default), the query matches on "",
- If `case_insensitive==true`, the query does not match on "".
We should make this consistent.
### Steps to Reproduce
Tested on an Elastic Cloud deployment with version 8.15.0-SNAPSHOT.
```
PUT term-match-test
{
"mappings": {
"properties": {
"text": {
"type": "keyword"
}
}
}
}
```
```
PUT term-match-test/_doc/1
{
"text": ""
}
```
Case sensitive search returns 1 hit:
```
POST term-match-test/_search
{
"query": {
"term": {
"text": {
"value": ""
}
}
}
}
```
Case insensitive search returns 0 hits:
```
POST term-match-test/_search
{
"query": {
"term": {
"text": {
"value": "",
"case_insensitive": true
}
}
}
}
```
### Logs (if relevant)
_No response_