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

Feature Request: Remove restriction on copy_to to non-child fields #34428

Closed
veqryn opened this issue Oct 13, 2018 · 3 comments
Closed

Feature Request: Remove restriction on copy_to to non-child fields #34428

veqryn opened this issue Oct 13, 2018 · 3 comments
Labels
>enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@veqryn
Copy link

veqryn commented Oct 13, 2018

I have data the is coming in like this, which I am unable to change:
{"tags":["foo=bar", "foo=quux", "blah=blarg"]}

You can see that there are keys (foo and blah) and values (bar, quux, and blarg).

I would like to be able to run aggregation queries against this in order to give me all the keys, with a sub-aggregation for all their values. (ie: how many times does "foo" key occur, and how many times does each of its bar and quux values occur?)

I could normally do this with a nested type, so I tried to make one:

{
  "mappings": {
    "thing": {
      "properties": {
        "tags": {
          "type": "keyword",
          "similarity": "boolean",
          "copy_to": ["ntags.key", "ntags.val"]
        },
        "ntags": {
          "type": "nested",
          "dynamic": false,
          "properties": {
            "key": {
              "type": "keyword",
              "similarity": "boolean",
              "normalizer": "key_normalizer"
            },
            "val": {
              "type": "keyword",
              "similarity": "boolean",
              "normalizer": "value_normalizer"
            }
          }
        }
      }
    }
  }
}

The key_normalizer just takes the string "foo=bar" and turns it into "foo". The value_normalizer turns it into "bar".

Turns out this is not allowed:
Illegal combination of [copy_to] and [nested] mappings: [copy_to] may only copy data to the current nested document or any of its parents, however one [copy_to] directive is trying to copy data from nested object [null] to [ntags]

So I also tried adding ntags as a multi-field underneath tags, but go this error, not that it would have helped since the copy_to probably doesn't work on sub-multi-fields anyway:
Type [nested] cannot be used in multi field

I can't change the format my data comes in as.

So... Is there something else I can do, either at index time or query time?
And if not, can the restriction on copy_to be removed?

(Some additional context here: https://discuss.elastic.co/t/how-to-sub-aggregate-an-array-that-contains-another-field/152155 )

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@polyfractal polyfractal added :Search Foundations/Mapping Index mappings, including merging and defining field types and removed :Analytics/Aggregations Aggregations labels May 21, 2019
@rjernst rjernst added the Team:Search Meta label for search team label May 4, 2020
@elasticsearchmachine
Copy link
Collaborator

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

@javanna
Copy link
Member

javanna commented Jun 24, 2024

This has been open for quite a while, and hasn't had a lot of interest. For now I'm going to close this as something we aren't planning on implementing. We can re-open it later if needed.

@javanna javanna closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2024
@javanna javanna added Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch and removed Team:Search Meta label for search team labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

9 participants