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

Give bulk requests the ability to give hints to dynamic mappings #61939

Closed
jpountz opened this issue Sep 3, 2020 · 3 comments · Fixed by #69948
Closed

Give bulk requests the ability to give hints to dynamic mappings #61939

jpountz opened this issue Sep 3, 2020 · 3 comments · Fixed by #69948
Assignees
Labels
>feature :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@jpountz
Copy link
Contributor

jpountz commented Sep 3, 2020

This feature consists of enabling dynamic templates to register arbitrary match_mapping_types, e.g.

PUT myindex
{
  "mappings": {
    "dynamic_templates": [{
      "time_histograms": {
        "match_mapping_type": "time_histogram", // defines a `time_histogram` type
        "mapping": {
          "type": "histogram",
          "meta": {
            "unit": "s"
          }
        }
      }
    }]
  }
}

And then allow bulk requests to tell Elasticseach what dynamic template to apply for a given field

POST myindex/_bulk
{ "index": { "match_mapping_types": { "response_times": "time_histogram" } } }
{ "@timestamp": "2020-08-12", "response_times": { "values": [1, 10], "counts": [5, 1] }}

This helps when ingesting data whose schema can't be known up-front, such as when collecting metrics from Promotheus or Statsd.

This syntax is an example, it's not set in stone, but the following points were considered:

  • Type hints are provided as part of the bulk request. Requiring a separate request to another API is not an option as we would lose atomicity (e.g. think of an alias being swapped) and ability to integrate with ingest processors.
  • The bulk request sends a match_mapping_type, not actual mappings. Sending actual mappings would be problematic as data shippers typically don't have enough privilege to do mapping updates.
  • Each index request within the bulk can set its own hints. Configuring this at the bulk level could be nice at some point, but we plan to use this feature via Ingest, at least initially, which works at the index request level.
@jpountz jpountz added >feature :Search Foundations/Mapping Index mappings, including merging and defining field types labels Sep 3, 2020
@elasticmachine
Copy link
Collaborator

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

@ruflin
Copy link
Member

ruflin commented Sep 7, 2020

If we have this feature, we could standardise on some match_mapping_types names and use the in the metrics-*-* base template. This would mean most metric ingestion with type hints just work out of the box.

@cyrille-leclerc
Copy link

Thank you very much @dnhatn . This histogram feature will greatly help observability!

dnhatn added a commit that referenced this issue Apr 8, 2021
This change allows users to specify dynamic templates in a bulk request.

```
PUT myindex
{
  "mappings": {
    "dynamic_templates": [{
      "time_histograms": {
        "mapping": {
          "type": "histogram",
          "meta": {
            "unit": "s"
          }
        }
      }
    }]
  }
}
```

```
POST myindex/_bulk
{ "index": { "dynamic_templates": { "response_times": "time_histograms" } } }
{ "@timestamp": "2020-08-12", "response_times": { "values": [1, 10], "counts": [5, 1] }}
```

Closes #61939
dnhatn added a commit that referenced this issue Apr 10, 2021
This change allows users to specify dynamic templates in a bulk request.

```
PUT myindex
{
  "mappings": {
    "dynamic_templates": [{
      "time_histograms": {
        "mapping": {
          "type": "histogram",
          "meta": {
            "unit": "s"
          }
        }
      }
    }]
  }
}
```

```
POST myindex/_bulk
{ "index": { "dynamic_templates": { "response_times": "time_histograms" } } }
{ "@timestamp": "2020-08-12", "response_times": { "values": [1, 10], "counts": [5, 1] }}
```

Closes #61939
@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
>feature :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

Successfully merging a pull request may close this issue.

7 participants