Elasticsearch 2.1 - Deprecated Search Types

According to this reference , two scanand countoutdated.

I am trying to modify my requests to reflect this. Thus, changing is counteasy by simply deleting the search type and adding size=0to the query, however I am not 100% of the change scan.

I currently have this query:

var result = ElasticClient.Search<Product>(s => s
    .From(0)
    .Size(10)
    .SearchType(SearchType.Scan)
    .Scroll("4s")
    .Query
        (qu =>
            qu.Filtered
                (fil =>
                    fil.Filter
                        (f =>
                            f.Bool(b => b.Must(m => m.Term("filedName", "abc")))))));

Do I understand correctly that all I need to change, delete searchtypeand add sort? I.e:

var result = ElasticClient.Search<Product>(s => s
    .From(0)
    .Size(10)
    .Scroll("4s")
    .Sort(x => x.OnField("_doc"))
    .Query
        (qu =>
            qu.Filtered
                (fil =>
                    fil.Filter
                        (f => f.Bool(b => b.Must(m => m.Term("filedName", "abc")))))));

I saw the listing SortSpecialField here , but I'm not sure how to use it in a parameter sort.

+4
source share
1 answer

, ( ) _doc Scan . SortSpecialField - _doc. , NEST 2.0 [only] :

ElasticClient.Search<Product>(s => s
.From(0)
.Size(10)
.Scroll("4s")
.Sort(x => x.Ascending(SortSpecialField.DocumentIndexOrder))
    ...
+4

Source: https://habr.com/ru/post/1624005/


All Articles