Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support case_insensitive in terms query #71520

Open
zhuming opened this issue Apr 9, 2021 · 7 comments
Open

support case_insensitive in terms query #71520

zhuming opened this issue Apr 9, 2021 · 7 comments
Labels
>enhancement :Search Relevance/Search Catch all for Search Relevance Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch

Comments

@zhuming
Copy link

zhuming commented Apr 9, 2021

Elasticsearch version (bin/elasticsearch --version):
7.10.2

Plugins installed: []
none

JVM version (java -version):
any

OS version (uname -a if on a Unix-like system):
any

Description of the problem including expected versus actual behavior:
Trying add case_insensitive:true to a terms query,

get alias_player/_search
{
  "query": {
    "terms": {
      "email": [
        "Diego.Maradona@fifa.com",
        "robert.BAGGIO@FIFA.com"
      ],
      "case_insensitive": true
    }
  }
}

and it failed with the below error info

{
    "type" : "parsing_exception",
    "reason" : "[terms] query does not support [case_insensitive]",
    "line" : 8,
    "col" : 27
}

case_insensitive works for term/query/wildcard, but not for terms

Steps to reproduce:

Please include a minimal but complete recreation of the problem,
including (e.g.) index creation, mappings, settings, query etc. The easier
you make for us to reproduce it, the more likely that somebody will take the
time to look at it.

  1. create a simple index with a keyword field, e.g. email, in the above example
  2. execute the above query
  3. elasticsearch fails to parse this request with case_insensitive flag

Provide logs (if relevant):

@zhuming zhuming added >bug needs:triage Requires assignment of a team area label labels Apr 9, 2021
@cbuescher
Copy link
Member

Hi @zhuming, I'm relabeling this as an enhancement request because I believe this parameter hasn't been supported for this type of query so far. We might decide to add it but I don't see that we did this in any previously released version. Please let me know if I'm mistaken on this.

@cbuescher cbuescher added :Search/Search Search-related issues that do not fall into other categories >enhancement and removed >bug labels Apr 12, 2021
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Apr 12, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@jimczi jimczi removed the needs:triage Requires assignment of a team area label label Apr 14, 2021
@davendu
Copy link

davendu commented Nov 26, 2021

For anyone interested: This was planned in #61162, and the last comment before issue closed already stated case_insensitive for terms is not implemented due to possible complexity explosion.

@SudoNova
Copy link

A workaround is using using a text field with

Record -> keyword tokenizer -> lowercase token filter

both as index and search analyzer. Performance and storage is blackbox here (for me, not the devs ofc ).
You may use a multiplexer before lowercase to preserve original keywords (text tokens).

@javanna
Copy link
Member

javanna commented Jan 11, 2023

Relates to #82825

@javanna
Copy link
Member

javanna commented Jan 26, 2023

We discussed this with the team and summarized the reasons why the functionality is not currently supported: TermsInSetQuery that the terms query is translated to in Lucene land does not support case insensitive queries. We would then have to automatically rewrite the query to a boolean query made of many low-level term queries, and there is a limit to the number of clauses that a boolean query can have.

Also, we would like to hear more about real usecases that would require terms to be case insensitive. Very often ids are looked up and they don't require analysis.

We would be happy to enable this feature once TermsInSetQuery supports it natively.

@benwtrent benwtrent added :Search Relevance/Search Catch all for Search Relevance and removed :Search/Search Search-related issues that do not fall into other categories labels Jul 12, 2024
@elasticsearchmachine elasticsearchmachine added Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch and removed Team:Search Meta label for search team labels Jul 12, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search Relevance/Search Catch all for Search Relevance Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

9 participants