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 for 'Include' of Terms Aggregation #68819

Open
tommymonk opened this issue Feb 10, 2021 · 9 comments
Open

Support case_insensitive for 'Include' of Terms Aggregation #68819

tommymonk opened this issue Feb 10, 2021 · 9 comments
Labels
:Analytics/Aggregations Aggregations >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@tommymonk
Copy link

tommymonk commented Feb 10, 2021

I noticed the recent 7.10 release bringing support for case insensitivity to more parts of the DSL (61546 & 59441)

I require the ability to filter Terms Aggregation buckets in a case-insensitive way.

GET /_search
{
  "aggs": {
    "tags": {
      "terms": {
        "field": "tags",
        "include": ".*sport.*",
        "include_case_insensitive": true
      }
    }
  }
}
@tommymonk tommymonk added >enhancement needs:triage Requires assignment of a team area label labels Feb 10, 2021
@cbuescher cbuescher added the :Analytics/Aggregations Aggregations label Feb 15, 2021
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Feb 15, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

@cbuescher cbuescher removed the needs:triage Requires assignment of a team area label label Feb 15, 2021
@tommymonk
Copy link
Author

Is there any update on this ?

@tommymonk
Copy link
Author

@cbuescher can someone take a look at this please.

@tommymonk
Copy link
Author

If this is being ignored because there is some easy workaround, please enlighten me

@awenger63
Copy link

Hi,
Perhaps you can add this to find result, but with this workarround, the result it's not the real value ...
"script": { "source": "_value.toLowerCase()" },

@tommymonk
Copy link
Author

Thanks @awenger63 I think that may work but then someone would raise a bug that the values are all lowercase, I will try thinking of a reliable way to fix the casing in code afterwards.

@nik9000
Copy link
Member

nik9000 commented Aug 9, 2021

Hey! I've been ignoring this one just because I can't read all the things and I figured someone else on the team was doing it. I was wrong. Anyway, would something this do what you want?

GET /_search
{
  "runtime_mappings": {
    "matching_tags": {
      "params": {
        "substring": "sport"
      },
      "script": """
for (String tag : doc.tags.values) {
  if (tag.toLowerCase(Locale.ROOT).contains(params.substring)) {
    emit(tag);
  }
}
      """
    }
  },
  "aggs": {
    "tags": {
      "terms": {
        "field": "matching_tags"
      }
    }
  }
}

Its certainly not the simplest work around because you have to lean on runtime fields and write a script instead of set a single setting but it does give you a bunch of flexibility. I think the script itself won't dominate the runtime here - I think you'll see the map flavored execution of terms doing all the work. But I think that'd be ok.

@tommymonk
Copy link
Author

Thanks @nik9000 I'll give this workaround a go when I get a chance.

Do you think there is much chance of this proposal getting worked as considering it's lack of complexity ?

@nik9000
Copy link
Member

nik9000 commented Aug 9, 2021

I think it's the kind of thing that we'd take a contribution for but won't have time to build ourselves. At least, I don't have time and don't know anyone who does.

I think I made a mess of the runtime field definition in my comment above. Sorry. I'll have to refer you to the docs to correct my mistakes: https://www.elastic.co/guide/en/elasticsearch/reference/7.14/runtime-search-request.html . That's what i get for trying to write a request at 7:45 without enough coffee in me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

No branches or pull requests

5 participants