elasticsearch/docs/reference/search
Nhat Nguyen 8d3ca4e755
Allow format sort values of date fields (#70357)
If a search after request targets multiple indices and some of its sort
field has type `date` in one index but `date_nanos` in other indices,
then Elasticsearch won't interpret the search_after parameter correctly
in every target index. The sort value of a date field by default is a
long of milliseconds since the epoch while a date_nanos field is a long
of nanoseconds.

This commit introduces the `format` parameter in the sort field so a
sort value of a date or date_nanos will be formatted using a date format
in a search response.

The below example illustrates how to use this new parameter.

```js
{
    "query": {
        "match_all": {}
    },
    "sort": [
        {
            "timestamp": {
                "order": "asc",
                "format": "strict_date_optional_time_nanos"
           }
        }
    ]
}
```

```js
{
    "query": {
        "match_all": {}
    },
    "sort": [
        {
            "timestamp": {
                "order": "asc",
                "format": "strict_date_optional_time_nanos"
            }
        }
    ],
    "search_after": [
        "2015-01-01T12:10:30.123456789Z" // in `strict_date_optional_time_nanos` format
    ]
}
```

Closes #69192
2021-03-21 11:28:45 -04:00
..
search-your-data Allow format sort values of date fields (#70357) 2021-03-21 11:28:45 -04:00
suggesters [DOCS] Fix minor suggester doc errors (#68244) (#68303) 2021-02-01 09:48:41 -05:00
async-search.asciidoc [DOCS] Fixes typo in async search API docs. (#70448) (#70457) 2021-03-17 10:50:00 +01:00
clear-scroll-api.asciidoc [DOCS] Fix case for 'Boolean' (#64299) (#64341) 2020-10-29 10:04:20 -04:00
count.asciidoc [DOCS] Add security privileges to search API docs (#68009) (#68492) 2021-02-03 16:53:19 -05:00
explain.asciidoc [DOCS] Add security privileges to search API docs (#68009) (#68492) 2021-02-03 16:53:19 -05:00
field-caps.asciidoc Add runtime field section to Field Capabilities API (#68904) (#68915) 2021-02-11 17:41:46 +01:00
multi-search.asciidoc [DOCS] Fix capitalization for Query DSL (#69236) (#69240) 2021-02-18 19:40:36 -05:00
point-in-time-api.asciidoc [DOCS] Document PIT security for aliases (#69572) (#69967) 2021-03-04 09:37:08 -05:00
point-in-time.asciidoc Retry point in time on other copy when possible (#66713) 2021-01-10 21:57:11 -05:00
profile.asciidoc [7.x] Revert "Remove aggregation's postCollect phase (#68942) 2021-02-11 20:46:53 -05:00
rank-eval.asciidoc [DOCS] Add security privileges to search API docs (#68009) (#68492) 2021-02-03 16:53:19 -05:00
scroll-api.asciidoc Improve user check for resource sharing and its documentation (#69844) (#70216) 2021-03-10 23:35:21 +11:00
search-shards.asciidoc [DOCS] Add security privileges to search API docs (#68009) (#68492) 2021-02-03 16:53:19 -05:00
search-template.asciidoc [DOCS] Fix caps for search template API docs (#68696) (#68703) 2021-02-08 13:59:06 -05:00
search.asciidoc [DOCS] Document PIT security for aliases (#69572) (#69967) 2021-03-04 09:37:08 -05:00
suggesters.asciidoc [DOCS] Fix minor suggester doc errors (#68244) (#68303) 2021-02-01 09:48:41 -05:00
validate.asciidoc [DOCS] Add security privileges to search API docs (#68009) (#68492) 2021-02-03 16:53:19 -05:00