Add default field API

edit

[preview] This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. In Elasticsearch 7.0 and later, some query types, such as Simple Query String, have a limit to the number of fields they can query against. To configure the cap in Elasticsearch, set the indices.query.bool.max_clause_count cluster setting, which is 1024 by default.

For indices with more fields than the cap, add the index.query.default_field index setting to inform Elasticsearch which fields to use by default when no field is specified for a query. Use the add default field API to add the index.query.default_field setting to an Elasticsearch index.

Request

edit

To add the index.query.default_field setting to an Elasticsearch index, submit a POST request to /api/upgrade_assistant/add_query_default_field/<index>:

GET /api/upgrade_assistant/add_query_default_field/myIndex
{
  "fieldTypes": ["text", "keyword"], 
  "otherFields": ["myField.*"] 
}

A required array of Elasticsearch field types that generate the list of fields.

An optional array of additional field names, dot-delimited.

To add the index.query.default_field index setting to the specified index, Kibana generates an array of all fields from the index mapping. The fields contain the types specified in fieldTypes. Kibana appends any other fields specified in otherFields to the array of default fields.

Response codes

edit
200
Indicates a successful call.
400
Indicates that the index already has the index.query.default_field setting. No changes are made to the index.

Response body

edit

The response body contains a JSON structure, similar to the following:

{
  "acknowledged": true
}

Example

edit

Your index contains following mappings:

GET /myIndex/_mappings
{
  "myIndex": {
    "mappings": {
      "properties": {
        "field1": { "type": "text" },
        "field2": { "type": "float" },
        "nestedfield": {
          "properties": {
            "field3": { "type": "keyword" },
            "field4": { "type": "long" },
          }
        }
      }
    }
  }
}

Make the following request to Kibana:

GET /api/upgrade_assistant/add_query_default_field/myIndex
{
  "fieldTypes": ["text", "long"],
  "otherFields": ["field2"]
}

The API returns the following:

GET /myIndex/_settings?flat_settings=true
{
  "myIndex": {
    "settings": {
      "index.query.default_field": [
        "field1",
        "nestedfield.field4",
        "field2",
      ]
    }
  }
}

Kibana generates the field1 and nestedfield.field4 values based on the specified fieldTypes, then appends the otherFields to the array.