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 dataThe 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; }
OtherSome new features or interfaces will continue to be replenished.