Elasticsearch-net: breaking changes search_type=scan and search_type=count deprecated in ES 2.1

Created on 20 Jan 2016  路  2Comments  路  Source: elastic/elasticsearch-net

According to ES these have been deprecated in 2.1.

https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_21_search_changes.html

For my particular use case I need to get the complete list of document IDs that match a search. I have been using search_type=scan. Would it be possible to add an enumeration for scroll to SearchType
so that it is used on the URL instead of scan?

ES now recommends getting all doc IDs using scroll and sorting by _doc.

GET /my_index/_search?scroll=2m
{
"sort": [
"_doc"
]
}

Thanks.

Most helpful comment

search_type=scan and search_type=count are deprecated in Elasticsearch 2.1 but NEST client 2.0 also needs to support ES 2.0.x so we would want to keep them for compatibility. Adding an enum value of scroll for search_type is not going to work because the SearchType enum sets the search_type query string parameter key and value which we don't want to set for scroll.

As @RobinRieger has noted, the way to acheive this using NEST 2.x and ES 2.1 is the following:

``` c#
var response = client.Search(s => s
.Scroll("2m")
.Sort(ss => ss
.Ascending(SortSpecialField.DocumentIndexOrder)
)
);

which will result in a request like

POST http://localhost:9200/_search?scroll=2m
{
"sort": [{
"_doc": {
"order": "asc"
}
}]
}
```

The default sort order for fields is ascending (except _score, whose default is descending).

All 2 comments

Does this question on StackOverflow help?

http://stackoverflow.com/questions/34754518/elasticsearch-2-1-deprecated-search-types

You say you need a complete list of document IDs, why can you not get them anymore?

search_type=scan and search_type=count are deprecated in Elasticsearch 2.1 but NEST client 2.0 also needs to support ES 2.0.x so we would want to keep them for compatibility. Adding an enum value of scroll for search_type is not going to work because the SearchType enum sets the search_type query string parameter key and value which we don't want to set for scroll.

As @RobinRieger has noted, the way to acheive this using NEST 2.x and ES 2.1 is the following:

``` c#
var response = client.Search(s => s
.Scroll("2m")
.Sort(ss => ss
.Ascending(SortSpecialField.DocumentIndexOrder)
)
);

which will result in a request like

POST http://localhost:9200/_search?scroll=2m
{
"sort": [{
"_doc": {
"order": "asc"
}
}]
}
```

The default sort order for fields is ascending (except _score, whose default is descending).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

foleta-developers picture foleta-developers  路  5Comments

iderbyshev picture iderbyshev  路  3Comments

ngonzalezromero picture ngonzalezromero  路  4Comments

meriturva picture meriturva  路  3Comments

codebrain picture codebrain  路  3Comments