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

breaking changes search_type=scan and search_type=count deprecated in ES 2.1 #1745

Closed
tiltracstevek opened this issue Jan 20, 2016 · 2 comments

Comments

@tiltracstevek
Copy link

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.

@RobinRieger
Copy link
Contributor

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?

@russcam
Copy link
Contributor

russcam commented Jan 21, 2016

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:

var response = client.Search<T>(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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants