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

API to list non-empty fields matched by a query DSL #52730

Closed
wylieconlon opened this issue Feb 24, 2020 · 3 comments
Closed

API to list non-empty fields matched by a query DSL #52730

wylieconlon opened this issue Feb 24, 2020 · 3 comments
Labels
:Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team

Comments

@wylieconlon
Copy link

Problem statement

A common interface element in Kibana is a list of "fields". These are displayed using the dotted path notation, such as browser.useragent and browser.useragent.keyword. To help the user with their choices, we want to provide the most accurate list possible. This usually involves starting with the list of field_caps and then filtering based on whether we think the paths returned contain data. To list some specific examples:

As you can see, this is a common request that is handled inconsistently.

Requirements of a solution

  • Takes a search query as input
  • For each potential path, calculate whether that field exists any docs in the search
  • Same response format as field_caps: list of fields as JSON, like { fieldName: { keyword: { aggregatable: true } } }.

Proposed API:

GET my_sample_data-*/_non_empty_fields
{
  query: {
    term: { 'event.dataset': 'system' }
  },
  include_unmapped: false,
  ignore_unavailable: false
}

Response:

{
  "indices": ["my_sample_data-1"],
  "fields": {
    "myField": { 
      "text": {
          "searchable": true,
          "aggregatable": false
      }
    },
    "myField.keyword": { 
      "keyword": {
        "searchable": true,
        "aggregatable": true
      }
    }
  }
}
@wylieconlon wylieconlon added the :Search/Search Search-related issues that do not fall into other categories label Feb 24, 2020
@elasticmachine
Copy link
Collaborator

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

@wylieconlon
Copy link
Author

Random sampling could potentially be used to make these queries fast: #53200

@jimczi
Copy link
Contributor

jimczi commented Jun 3, 2020

Closing in favor of #56195 which will add index filtering capabilities in the _field_caps API

@jimczi jimczi closed this as completed Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team
Projects
None yet
Development

No branches or pull requests

4 participants