Elasticsearch_.net_client_nest2.x_ to _5.x common method attribute differences

Source: Internet
Author: User

Change 1 field type string
  • There are only string types in 2.x, which can be used to set whether participle, index, and word breaker.
  • 5.x split into Keyword type and text type, Keyword not participle, can be set whether indexed; text participle, can be set whether the index and word breaker used.
    [String (Name ="Name", Index =fieldindexoption.notanalyzed)] Public stringName {Get;Set; } [String (Name="Dic", Index = Fieldindexoption.analyzed,analyzer ="Ik_max_word")]           /// <summary>        ///keyword no participle/// </summary>[Keyword (Name ="Name", Index =true)]         Public stringName {Get;Set; } /// <summary>        ///text participle, Analyzer = "Ik_max_word"/// </summary>[Text (Name ="Dic", Index =true, Analyzer ="Ik_max_word")]         Public stringDic {Get;Set; }

    Note: 5.x has marked string as obsolete and the next version will be removed;

    Change 2 scroll scan to get full amount of data

    The rolling scan supports parallel execution to improve the efficiency of data acquisition.

    2.x

     Public voidSearchscanscroll (stringIndexName) {            stringScrollid =""; varresult = _client. Search<testmodel2> (s = S.index (IndexName). Query (q =Q.matchall ()). Size (Ten)                //removal of searchtype.scan,5.x in todo:2x                . SearchType (Searchtype.scan). Scroll ("1m")); Scrollid=result.            Scrollid; intCount =0;  while(true)            {                //get the ID of the scroll scan//performing a rolling scan to get the amount of data returned is result. Shards.successful*size (number of shards successfully queried *size)                varRESULT1 = _client. Scroll<testmodel2> ("1m", Scrollid); if(RESULT1. documents==NULL|| !RESULT1. Documents.any ()) Break; foreach(varInfoinchRESULT1. Documents) {Count++; Console.WriteLine (Info. Id+" - "+count); }                //get the new IDScrollid =RESULT1.            Scrollid; }        }

    5.x

    action<int> SC1 = (id) = =            {                stringScrollid =""; //todo:5.x More Slice set remove Searchtype.scan                varresult = _client. Search<testmodel5> (s = S.index (IndexName). Query (q =Q.matchall ()). Size ( the)                    . Sort (St=>st. Descending (ds=>ds. ID)). Scroll ("1m")                    //ID starting from 0 0,1,2 ... //Length=max//Example: max=3 id=0,id=1,id=2. Slice (SL = SL). ID (ID). Max (3))                    ); //get the ID of the scroll scanScrollid =result.                Scrollid; foreach(varInfoinchresult. Documents) {Console.WriteLine (info). Id+" - "+"-Batch Count"+ result. Documents.count +"-Thread"+Thread.CurrentThread.ManagedThreadId); }                 while(true)                {                    //performing a rolling scan to get the amount of data returned is result. Shards.successful*size (number of shards successfully queried *size)                    varRESULT1 = _client. Scroll<testmodel5> ("1m", Scrollid); if(RESULT1. Documents = =NULL|| !RESULT1. Documents.any ()) Break; foreach(varInfoinchRESULT1. Documents) {Console.WriteLine (info). Id+" - "+"-Batch Count"+ RESULT1. documents.count+"-Thread"+Thread.CurrentThread.ManagedThreadId); }                    //get the new IDScrollid =RESULT1.                Scrollid;           }            }; varT1= Task.Factory.StartNew (() = {SC1 (0);            }); varT2= Task.Factory.StartNew (() = {SC1 (1);            }); varT3= Task.Factory.StartNew (() = {SC1 (2);            }); T1.            Wait (); T2.            Wait (); T3. Wait ();

    Note: 5.x adds slice settings to pull the full amount of data in parallel, remove Searchtype.scan, and return results when searching for search for the first time, 2.x set Searchtype.scan first search returns only Scrollid.

    Note: The depth paging scheme is added in 5.x in depth page

    Grouping result Objects Nest.keyedbucket
      • 2.x Keyedbucket
      • 5.x Keyedbucket<object>

    Aggregation result parsing

    2.x

               varVendoridgroup = (bucketaggregate) result. aggregations["Group_group"]; foreach(varBucket1inchvendoridgroup.items) {//todo:2.x Keyedbucket                varBucket =(Keyedbucket) Bucket1; varMaxprice = ((valueaggregate) bucket. aggregations["Dvalue_max"]).            Value; }

    5.x

                varVendoridgroup = (bucketaggregate) result. aggregations["Group_group"]; foreach(varBucket1inchvendoridgroup.items) {//todo:5.x keyedbucket<t>                varBucket = (keyedbucket<Object>) Bucket1; varMaxprice = ((valueaggregate) bucket. aggregations["Dvalue_max"]).            Value; }
    Other

    Some new features or interfaces will continue to be replenished.

Elasticsearch_.net_client_nest2.x_ to _5.x common method attribute differences

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.