elasticsearch/docs/reference/search
Nhat Nguyen 8b5aa84647
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-16 21:27:51 -04:00
..
search-your-data Allow format sort values of date fields (#70357) 2021-03-16 21:27:51 -04:00
suggesters [DOCS] Fix minor suggester doc errors (#68244) 2021-02-01 09:33:12 -05:00
async-search.asciidoc [DOCS] Fixes typo in async search API docs. (#70448) 2021-03-16 14:36:12 +01:00
clear-scroll-api.asciidoc [DOCS] Fix case for 'Boolean' (#64299) 2020-10-29 09:04:43 -04:00
count.asciidoc [DOCS] Add security privileges to search API docs (#68009) 2021-02-03 16:30:51 -05:00
explain.asciidoc [DOCS] Add security privileges to search API docs (#68009) 2021-02-03 16:30:51 -05:00
field-caps.asciidoc Add runtime field section to Field Capabilities API (#68904) 2021-02-11 16:20:18 +01:00
multi-search.asciidoc [DOCS] Fix capitalization for Query DSL (#69236) 2021-02-18 18:57:19 -05:00
point-in-time-api.asciidoc [DOCS] Document PIT security for aliases (#69572) 2021-03-04 08:42:42 -05:00
profile.asciidoc Revert "Remove aggregation's postCollect phase (#68615) 2021-02-10 19:12:50 -05:00
rank-eval.asciidoc [DOCS] Add security privileges to search API docs (#68009) 2021-02-03 16:30:51 -05:00
scroll-api.asciidoc Improve user check for resource sharing and its documentation (#69844) 2021-03-10 21:55:50 +11:00
search-shards.asciidoc [DOCS] Add security privileges to search API docs (#68009) 2021-02-03 16:30:51 -05:00
search-template.asciidoc [DOCS] Fix caps for search template API docs (#68696) 2021-02-08 13:24:02 -05:00
search.asciidoc [DOCS] Document PIT security for aliases (#69572) 2021-03-04 08:42:42 -05:00
suggesters.asciidoc [DOCS] Fix minor suggester doc errors (#68244) 2021-02-01 09:33:12 -05:00
validate.asciidoc [DOCS] Add security privileges to search API docs (#68009) 2021-02-03 16:30:51 -05:00