Elasticsearch .net client NEST使用说明 2.x -更新版
2017-06-27 15:10
681 查看
Elasticsearch.netclientNEST使用说明
目录:引用
引用dllNEST.dll Elasticsearch.Net.dll Newtonsoft.Json.dll注:仅支持.netframework>=4.5
概念
存储结构:
在Elasticsearch中,文档(Document)归属于一种类型(type),而这些类型存在于索引(index)中.类比传统关系型数据库:RelationalDB->Databases->Tables->Rows->Columns Elasticsearch->Indices->Types->Documents->Fields
客户端语法
链式lambda表达式(powerfulqueryDSL)语法
s=>s.Query(q=>q .Term(p=>p.Name,"elasticsearch") )
对象初始化语法
varsearchRequest=newSearchRequest<VendorPriceInfo> { Query=newTermQuery { Field="name", Value="elasticsearch" } };
Connection链接
//单node Varnode=newUri(“……”); varsettings=newConnectionSettings(node); //多uris Varuris=newUri[]{ newUri(“……”), newUri(“……”) }; varpool=newStaticConnectionPool(uris); //多node Varnodes=newNode[]{ newNode(newUri(“……”)), newNode(newUri(“……”)) }; varpool=newStaticConnectionPool(nodes); varsettings=newConnectionSettings(pool); varclient=newElasticClient(settings);注:nest默认字段名首字母小写,如果要设置为与Model中一致按如下设置。(强烈建议使用该设置)
varsettings=newConnectionSettings(node).DefaultFieldNameInferrer((name)=>name);
连接池类型
//单节点 IConnectionPoolpool=newSingleNodeConnectionPool(urls.FirstOrDefault()); //请求时随机发送请求到各个正常的节点,不请求异常节点,异常节点恢复后会重新被请求 IConnectionPoolpool=newStaticConnectionPool(urls); IConnectionPoolpool=newSniffingConnectionPool(urls); //false.创建客户端时,随机选择一个节点作为客户端的请求对象,该节点异常后不会切换其它节点 //true,请求时随机请求各个正常节点,不请求异常节点,但异常节点恢复后不会重新被请求 pool.SniffedOnStartup=true; //创建客户端时,选择第一个节点作为请求主节点,该节点异常后会切换其它节点,待主节点恢复后会自动切换回来 IConnectionPoolpool=newStickyConnectionPool(urls);
索引选择
方式1
//链接设置时设置默认使用索引 varsettings=newConnectionSettings().DefaultIndex("defaultindex");
方式2
//链接设置时设置索引与类型对应关系,操作时根据类型使用对应的索引 varsettings=newConnectionSettings().MapDefaultTypeIndices(m=>m.Add(typeof(Project),"projects"));
方式3
//执行操作时指定索引 client.Search<VendorPriceInfo>(s=>s.Index("test-index")); client.Index(data,o=>o.Index("test-index"));优先级:方式3>方式2>方式1
索引(Index)
数据唯一Id
1)默认以“Id”字段值作为索引唯一Id值,无“Id”属性,Es自动生成唯一Id值,添加数据时统一类型数据唯一ID已存在相等值,将只做更新处理。注:自动生成的ID有22个字符长,URL-safe,Base64-encodedstringuniversallyuniqueidentifiers,或者叫UUIDs。2) 标记唯一Id值[ElasticsearchType(IdProperty="priceID")]publicclassVendorPriceInfo{publicInt64priceID{get;set;}publicintoldID{get;set;}publicintsource{get;set;}}3)索引时指定
client.Index(data,o=>o.Id(data.vendorName));优先级:3)>2)>1)
类型(Type)
1)默认类型为索引数据的类名(自动转换为全小写)2)标记类型[ElasticsearchType(Name="datatype")]publicclassVendorPriceInfo{publicInt64priceID{get;set;}publicintoldID{get;set;}publicintsource{get;set;}}3)索引时指定
client.Index(data,o=>o.Type(newTypeName(){Name="datatype",Type=typeof(VendorPriceInfo)}));或
client.Index(data,o=>o.Type<MyClass>());//使用2)标记的类型优先级:3)>2)>1)
创建
client.CreateIndex("test2");//基本配置IIndexStateindexState=newIndexState(){Settings=newIndexSettings(){NumberOfReplicas=1,//副本数NumberOfShards=5//分片数}};client.CreateIndex("test2",p=>p.InitializeUsing(indexState));//创建并Mappingclient.CreateIndex("test-index3",p=>p.InitializeUsing(indexState).Mappings(m=>m.Map<VendorPriceInfo>(mp=>mp.AutoMap())));注:索引名称必须小写
判断
client.IndexExists("test2");
删除
client.DeleteIndex("test2");
映射
概念
每个类型拥有自己的映射(mapping)或者模式定义(schemadefinition)。一个映射定义了字段类型、每个字段的数据类型、以及字段被Elasticsearch处理的方式。获取映射
varresule=client.GetMapping<VendorPriceInfo>();
特性
///<summary>///VendorPrice实体///</summary>[ElasticsearchType(IdProperty="priceID",Name="VendorPriceInfo")]publicclassVendorPriceInfo{[Number(NumberType.Long)]publicInt64priceID{get;set;}[Date(Format="mmddyyyy")]publicDateTimemodifyTime{get;set;}///<summary>///如果string类型的字段不需要被分析器拆分,要作为一个正体进行查询,需标记此声明,否则索引的值将被分析器拆分///</summary>[String(Index=FieldIndexOption.NotAnalyzed)]publicstringpvc_Name{get;set;}///<summary>///设置索引时字段的名称///</summary>[String(Name="PvcDesc")]publicstringpvc_Desc{get;set;}///<summary>///如需使用坐标点类型需添加坐标点特性,在maping时会自动映射类型///</summary>[GeoPoint(Name="ZuoBiao",LatLon=true)]publicGeoLocationLocation{get;set;}}
映射
//根据对象类型自动映射varresult=client.Map<VendorPriceInfo>(m=>m.AutoMap());//手动指定varresult1=client.Map<VendorPriceInfo>(m=>m.Properties(p=>p.GeoPoint(gp=>gp.Name(n=>n.Location)//坐标点类型.Fielddata(fd=>fd.Format(GeoPointFielddataFormat.Compressed)//格式arraydoc_valuescompresseddisabled.Precision(newDistance(2,DistanceUnit.Meters))//精确度)).String(s=>s.Name(n=>n.b_id))//string类型));//在原有字段下新增字段(用于存储不同格式的数据,查询使用该字段方法查看【基本搜索】)//eg:在vendorName下添加无需分析器分析的值tempvarresult2=client.Map<VendorPriceInfo>(m=>m.Properties(p=>p.String(s=>s.Name(n=>n.vendorName).Fields(fd=>fd.String(ss=>ss.Name("temp").Index(FieldIndexOption.NotAnalyzed))))));注:映射时已存在的字段将无法重新映射,只有新加的字段能映射成功。所以最好在首次创建索引后先进性映射再索引数据。注:映射时同一索引中,多个类型中如果有相同字段名,那么在索引时可能会出现问题(会使用第一个映射类型)。
数据
数据操作
说明
添加数据时,如果文档的唯一id在索引里已存在,那么会替换掉原数据;添加数据时,如果索引不存在,服务会自动创建索引;如果服务自动创建索引,并索引了数据,那么索引的映射关系就是服务器自动设置的;通常正确的使用方法是在紧接着创建索引操作之后进行映射关系的操作,以保证索引数据的映射是正确的。然后才是索引数据;文档在Elasticsearch中是不可变的,执行Update事实上Elasticsearch的处理过程如下:从旧文档中检索JSON修改JSON值删除旧文档索引新文档所以我们也可以使用Index来更新已存在文档,只需对应文档的唯一id。添加索引数据
添加单条数据
vardata=newVendorPriceInfo(){vendorName="测试"};client.Index(data);
添加多条数据
vardatas=newList<VendorPriceInfo>{newVendorPriceInfo(){priceID=1,vendorName="test1"},newVendorPriceInfo(){priceID=2,vendorName="test2"}};client.IndexMany(datas);
删除数据
单条数据
DocumentPath<VendorPriceInfo>deletePath=newDocumentPath<VendorPriceInfo>(7);client.Delete(deletePath);或
IDeleteRequestrequest=newDeleteRequest("test3","vendorpriceinfo",0);client.Delete(request);注:删除时根据唯一id删除
集合数据
Indicesindices="test-1";Typestypes="vendorpriceinfo";//批量删除需要es安装delete-by-query插件varresult=client.DeleteByQuery<VendorPriceInfo>(indices,types,dq=>dq.Query(q=>q.TermRange(tr=>tr.Field(fd=>fd.priceID).GreaterThanOrEquals("5").LessThanOrEquals("10"))));
更新数据
更新所有字段
DocumentPath<VendorPriceInfo>deletePath=newDocumentPath<VendorPriceInfo>(2);Varresponse=client.Update(deletePath,(p)=>p.Doc(newVendorPriceInfo(){vendorName="test2update..."}));//或IUpdateRequest<VendorPriceInfo,VendorPriceInfo>request=newUpdateRequest<VendorPriceInfo,VendorPriceInfo>(deletePath){Doc=newVendorPriceInfo(){priceID=888,vendorName="test4update........"}};varresponse=client.Update<VendorPriceInfo,VendorPriceInfo>(request);
更新部分字段
IUpdateRequest<VendorPriceInfo,VendorPriceInfoP>request=newUpdateRequest<VendorPriceInfo,VendorPriceInfoP>(deletePath){Doc=newVendorPriceInfoP(){priceID=888,vendorName="test4update........"}};varresponse=client.Update(request);
更新部分字段
IUpdateRequest<VendorPriceInfo,object>request=newUpdateRequest<VendorPriceInfo,object>(deletePath){Doc=new{priceID=888,vendorName="test4update........"}};varresponse=client.Update(request);//或client.Update<VendorPriceInfo,object>(deletePath,upt=>upt.Doc(new{vendorName="ptptptptp"}));注:更新时根据唯一id更新
更新时使用本版号加锁机制
//查询到版本号varresult=client.Search<MessageInfo>(s=>s.Index("ep_epdb8buddy_imchatinfo_messageinfo_nopaging_msguid_index").Type("MessageInfo").Query(q=>q.Term(tm=>tm.Field("MsgUID").Value("5DCC-A8C4-44NV-VKGU"))).Size(1).Version());foreach(varsinresult.Hits){Console.WriteLine(s.Id+"-"+s.Version);}varpath=newDocumentPath<MessageInfo>("5DCC-A8C4-44NV-VKGU");//更新时带上版本号如果服务端版本号与传入的版本好相同才能更新成功varresponse=client.Update(path,(p)=>p.Index("ep_epdb8buddy_imchatinfo_messageinfo_nopaging_msguid_index-2017.03").Type("MessageInfo").Version(2).Doc(newMessageInfo(){MsgUID="5DCC-A8C4-44NV-VKGU",FromUserName="测测测"+DateTime.Now}));
获取数据
varresponse=client.Get(newDocumentPath<VendorPriceInfo>(0));//或varresponse=client.Get(newDocumentPath<VendorPriceInfo>(0),pd=>pd.Index("test4").Type("v2"));//多个varresponse=client.MultiGet(m=>m.GetMany<VendorPriceInfo>(newList<long>{1,2,3,4}));注:获取时根据唯一id获取
批处理操作
varlistOps=newList<IBulkOperation>{//更新newBulkUpdateOperation<VendorOfferNewsByCsId,object>(newVendorOfferNewsByCsId(){},new{Name="new-project2"}){Id="3"},//删除newBulkDeleteOperation<VendorOfferNewsByCsId>(newId(1))//...};IBulkRequestbulkRequest=newBulkRequest("indexname","typename");varrequest=newBulkRequest(){Operations=listOps};client.Bulk(request);
搜索
说明
搜索分页时随着分页深入,资源花费是成倍增长的。限制from+size⇐10000分页说明资料资料需要扫描所有数据时,使用滚屏扫描。扫描与滚屏资料搜索中提供了查询(Query)和过滤(Filter):query是要计算相关性评分的,filter不要;query结果不缓存,filter缓存。全文搜索、评分排序,使用query;是非过滤,精确匹配,使用filter。基本搜索
varresult=client.Search<VendorPriceInfo>(s=>s.Explain()//参数可以提供查询的更多详情。.FielddataFields(fs=>fs//对指定字段进行分析.Field(p=>p.vendorFullName).Field(p=>p.cbName)).From(0)//跳过的数据个数.Size(50)//返回数据个数.Query(q=>q.Term(p=>p.vendorID,100)//主要用于精确匹配哪些值,比如数字,日期,布尔值或not_analyzed的字符串(未经分析的文本数据类型):&&q.Term(p=>p.vendorName.Suffix("temp"),"姓名")//用于自定义属性的查询(定义方法查看MappingDemo)&&q.Bool(//bool查询b=>b.Must(mt=>mt//所有分句必须全部匹配,与AND相同.TermRange(p=>p.Field(f=>f.priceID).GreaterThan("0").LessThan("1")))//指定范围查找.Should(sd=>sd//至少有一个分句匹配,与OR相同.Term(p=>p.priceID,32915),sd=>sd.Terms(t=>t.Field(fd=>fd.priceID).Terms(new[]{10,20,30})),//多值//||//sd.Term(p=>p.priceID,1001)//||//sd.Term(p=>p.priceID,1005)sd=>sd.TermRange(tr=>tr.GreaterThan("10").LessThan("12").Field(f=>f.vendorPrice))).MustNot(mn=>mn//所有分句都必须不匹配,与NOT相同.Term(p=>p.priceID,1001),mn=>mn.Bool(bb=>bb.Must(mt=>mt.Match(mc=>mc.Field(fd=>fd.carName).Query("至尊")))))))//查询条件.Sort(st=>st.Ascending(asc=>asc.vendorPrice))//排序.Source(sc=>sc.Include(ic=>ic.Fields(fd=>fd.vendorName,fd=>fd.vendorID,fd=>fd.priceID,fd=>fd.vendorPrice)))//返回特定的字段);//TResultvarresult1=client.Search<VendorPriceInfo,VendorPriceInfoP>(s=>s.Query(q=>q.MatchAll()).Size(15));或
varresult=client.Search<VendorPriceInfo>(newSearchRequest(){Sort=newList<ISort>{newSortField{Field="vendorPrice",Order=SortOrder.Ascending}},Size=10,From=0,Query=newTermQuery(){Field="priceID",Value=6}||newTermQuery({Field="priceID",Value=8}});
动态拼接条件、排序
//must条件varmustQuerys=newList<Func<QueryContainerDescriptor<VendorOfferNewsByCsId>,QueryContainer>>();//车型mustQuerys.Add(mt=>mt.Term(tm=>tm.Field(fd=>fd.csID).Value(csid)));//should条件varshouldQuerys=newList<Func<QueryContainerDescriptor<VendorOfferNewsByCsId>,QueryContainer>>();//车型shouldQuerys.Add(mt=>mt.Term(tm=>tm.Field(fd=>fd.csID).Value(csid)));//排序Func<SortDescriptor<VendorOfferNewsByCsId>,IPromise<IList<ISort>>>sortDesc=sd=>{//根据分值排序sd.Descending(SortSpecialField.Score);//排序if(ispc)sd.Descending(d=>d.pDimWeightSort);elsesd.Descending(d=>d.mDimWeightSort);returnsd;};varresult2=client.Search<VendorOfferNewsByCsId>(s=>s.Index("vendoroffernewsbycsidinfo").Type("vendoroffernewsbycsidinfo").Query(q=>q.Bool(b=>b.Must(mustQuerys).Should(shouldQuerys))).Size(100).From(0).Sort(sortDesc));
分页
//分页最大限制(from+size<=10000)intpageSize=10;intpageIndex=1;varresult=client.Search<VendorPriceInfo>(s=>s.Query(q=>q.MatchAll()).Size(pageSize).From((pageIndex-1)*pageSize).Sort(st=>st.Descending(d=>d.priceID)));
扫描和滚屏
stringscrollid="";varresult=client.Search<VendorPriceInfo>(s=>s.Query(q=>q.MatchAll()).Size(100).SearchType(SearchType.Scan).Scroll("1m"));//scrollid过期时间//得到滚动扫描的idscrollid=result.ScrollId;//执行滚动扫描得到数据返回数据量是result.Shards.Successful*size(查询成功的分片数*size)result=client.Scroll<VendorPriceInfo>("1m",scrollid);//得到新的idscrollid=result.ScrollId;
查询条件相关性加权
eg:通过城市与省份查询,设置城市的相关性高于省份的,结果的等分匹配城市的将高于匹配省份的。//在原分值基础上设置不同匹配的加成值具体算法为lucene内部算法varresult=client.Search<VendorPriceInfo>(s=>s.Query(q=>q.Term(t=>t.Field(f=>f.cityID).Value(2108).Boost(4))||q.Term(t=>t.Field(f=>f.pvcId).Value(2103).Boost(1))).Size(3000).Sort(st=>st.Descending(SortSpecialField.Score)));
得分控制
//使用functionscore计算得分varresult1=client.Search<VendorPriceInfo>(s=>s.Query(q=>q.FunctionScore(f=>f //查询区.Query(qq=>qq.Term(t=>t.Field(fd=>fd.cityID).Value(2108))||qq.Term(t=>t.Field(fd=>fd.pvcId).Value(2103))).Boost(1.0)//functionscore对分值影响.BoostMode(FunctionBoostMode.Replace)//计算boost模式;Replace为替换.ScoreMode(FunctionScoreMode.Sum)//计算score模式;Sum为累加//逻辑区.Functions(fun=>fun.Weight(w=>w.Weight(2).Filter(ft=>ft.Term(t=>t.Field(fd=>fd.cityID).Value(2108))))//匹配cityid+2.Weight(w=>w.Weight(1).Filter(ft=>ft.Term(t=>t.Field(fd=>fd.pvcId).Value(2103))))//匹配pvcid+1))).Size(3000).Sort(st=>st.Descending(SortSpecialField.Score).Descending(dsc=>dsc.priceID)));//结果中cityid=2108,得分=2;pvcid=2103,得分=1,两者都满足的,得分=3
查询字符串-简单的检索
varresult=client.Search<VendorPriceInfo>(s=>s.Query(q=>q.QueryString(m=>m.Fields(fd=>fd.Field(fdd=>fdd.carName).Field(fdd=>fdd.carGearBox)).Query("手自一体"))).From(0).Size(15));
全文检索-关键词搜索
varresult=client.Search<VendorPriceInfo>(s=>s.Query(q=>q.Match(m=>m.Field(f=>f.carName).Query("尊贵型"))).From(0).Size(15));//多字段匹配varresult1=client.Search<VendorPriceInfo>(s=>s.Query(q=>q.MultiMatch(m=>m.Fields(fd=>fd.Fields(f=>f.carName,f=>f.carGearBox)).Query("尊贵型"))).From(0).Size(15));
全文搜索-短语搜索
varresult=client.Search<VendorPriceInfo>(s=>s.Query(q=>q.MatchPhrase(m=>m.Field(f=>f.carName).Query("尊贵型"))).From(0).Size(15));
坐标点搜索-根据坐标点及距离搜索
eg:搜索指定地点附近所有经销商constdoublelat=39.8694890000;constdoublelon=116.4206470000;constdoubledistance=2000.0;//1bool查询中作为must一个条件varresult=client.Search<VendorPriceInfo>(s=>s.Query(q=>q.Bool(b=>b.Must(m=>m.GeoDistance(gd=>gd.Location(lat,lon).Distance(distance,DistanceUnit.Meters).Field(fd=>fd.Location))))).From(0).Size(15));//2与bool查询同级条件varlocation=newGeoLocation(lat,lon);vardistancei=newDistance(distance,DistanceUnit.Meters);varresult1=client.Search<VendorPriceInfo>(s=>s.Query(q=>q.Bool(b=>b.Must(m=>m.Exists(e=>e.Field(fd=>fd.Location))))&&q.GeoDistance(gd=>gd.Location(location).Distance(distancei).Field(fd=>fd.Location))).From(0).Size(15));//3作为bool查询中must的一个筛选项-筛选项只筛选结果不会影响分值varresult2=client.Search<VendorPriceInfo>(s=>s.Query(q=>q.Bool(b=>b.Must(m=>m.MatchAll()).Filter(f=>f.GeoDistance(g=>g.Name("named_query").Field(p=>p.Location).DistanceType(GeoDistanceType.Arc).Location(lat,lon).Distance("2000.0m"))))).From(0).Size(15));
聚合
聚合-基本
varresult=client.Search<VendorPriceInfo>(s=>s.From(0).Size(15).Aggregations(ag=>ag.ValueCount("Count",vc=>vc.Field(fd=>fd.vendorPrice))//总数.Sum("vendorPrice_Sum",su=>su.Field(fd=>fd.vendorPrice))//求和.Max("vendorPrice_Max",m=>m.Field(fd=>fd.vendorPrice))//最大值.Min("vendorPrice_Min",m=>m.Field(fd=>fd.vendorPrice))//最小值.Average("vendorPrice_Avg",avg=>avg.Field(fd=>fd.vendorPrice))//平均值.Terms("vendorID_group",t=>t.Field(fd=>fd.vendorID).Size(100))//分组));
聚合-分组
eg:统计每个经销商下的平均报价//每个经销商的平均报价varresult=client.Search<VendorPriceInfo>(s=>s.Size(0).Aggregations(ag=>ag.Terms("vendorID_group",t=>t.Field(fd=>fd.vendorID).Size(100).Aggregations(agg=>agg//分组后取每组内多少条源数据.TopHits("top_vendor_hits",th=>th.Sort(srt=>srt.Field(fd=>fd.newsId).Descending()).Size(1)).Average("vendorID_Price_Avg",av=>av.Field(fd=>fd.vendorPrice))))//分组.Cardinality("vendorID_group_count",dy=>dy.Field(fd=>fd.vendorID))//分组数量.ValueCount("Count",c=>c.Field(fd=>fd.vendorID))//总记录数));
聚合-分组-聚合..
eg:统计每个经销商对每个品牌的平均报价、最高报价、最低报价等//每个经销商下每个品牌的平均报价varresult=client.Search<VendorPriceInfo>(s=>s.Size(0).Aggregations(ag=>ag.Terms("vendorID_group",//vendorID分组t=>t.Field(fd=>fd.vendorID).Size(100).Aggregations(agg=>agg.Terms("vendorID_cbID_group",//cbID分组tt=>tt.Field(fd=>fd.cbID).Size(50).Aggregations(aggg=>aggg.Average("vendorID_cbID_Price_Avg",av=>av.Field(fd=>fd.vendorPrice))//Priceavg.Max("vendorID_cbID_Price_Max",m=>m.Field(fd=>fd.vendorPrice))//Pricemax.Min("vendorID_cbID_Price_Min",m=>m.Field(fd=>fd.vendorPrice))//Pricemin.ValueCount("vendorID_cbID_Count",m=>m.Field(fd=>fd.cbID))//该经销商对该品牌报价数count)).Cardinality("vendorID_cbID_group_count",dy=>dy.Field(fd=>fd.cbID))//分组数量.ValueCount("vendorID_Count",c=>c.Field(fd=>fd.vendorID))//该经销商的报价数)).Cardinality("vendorID_group_count",dy=>dy.Field(fd=>fd.vendorID))//分组数量.ValueCount("Count",c=>c.Field(fd=>fd.priceID))//总记录数)//分组);
复杂聚合分组及结果解析
intvendorBizMode=2;intcId=2501;intcsid=1914;varmustQuerys=newList<Func<QueryContainerDescriptor<VendorOfferNewsInfo>,QueryContainer>>();mustQuerys.Add(t=>t.Term(f=>f.csID,csid));//mustQuerys.Add(t=>t.Term(f=>f.cId,cId));mustQuerys.Add(t=>t.Term(f=>f.vendorBizMode,vendorBizMode));varresult=client.Search<VendorOfferNewsInfo>(s=>s.Index("vendoroffernewsinfo").Type("vendoroffernewsinfo").Query(q=>q.Bool(b=>b.Must(mustQuerys))).Size(0).Sort(st=>st.Descending(SortSpecialField.Score).Descending(dsc=>dsc.mDimWeightSort)).Aggregations(ag=>ag.Terms("VendorID_Group",tm=>tm.OrderDescending("mDimWeightSort_avg").Field(fd=>fd.VendorID).Size(100).Aggregations(agg=>agg.TopHits("top_vendor_hits",th=>th.Sort(srt=>srt.Field(fd=>fd.newsId).Descending()).Size(1)).Max("vendorPrice_Max",m=>m.Field(fd=>fd.OrderPrice)).Min("vendorPrice_Min",m=>m.Field(fd=>fd.OrderPrice)).Average("mDimWeightSort_avg",avg=>avg.Field(fd=>fd.mDimWeightSort))))));varvendorIdGroup=(BucketAggregate)result.Aggregations["VendorID_Group"];varresultInfos=newList<VendorOfferNewsInfo>();foreach(varbucket1invendorIdGroup.Items){varbucket=(KeyedBucket)bucket1;varmaxPrice=((ValueAggregate)bucket.Aggregations["vendorPrice_Max"]).Value;varminPrice=((ValueAggregate)bucket.Aggregations["vendorPrice_Min"]).Value;varsources=((TopHitsAggregate)bucket.Aggregations["top_vendor_hits"]).Documents<VendorOfferNewsInfo>().ToList();vardata=sources.FirstOrDefault();data.MaxPrice=(decimal)maxPrice;data.MinPrice=(decimal)minPrice;resultInfos.Add(data);}varss=resultInfos;
附
距离单位:
mm(毫米)cm(厘米)m(米)km(千米)in(英寸)ft(英尺)yd(码)mi(英里)nmiorNM(海里)日期单位:
y(year)M(month)w(week)d(day)h(hour)m(minute)s(second)ms(milliseconds)官网文档
Elasticsearch.Net、NEST交流群:523061899
相关文章推荐
- Elasticsearch .Net Client NEST使用说明 2.x
- Elasticsearch .net client NEST使用说明
- Elasticsearch .net client NEST 5.x 使用总结
- Elasticsearch.net client NEST 5.x 使用总结
- Elasticsearch .net client NEST 5.x 使用总结
- (转)NEST.net Client For Elasticsearch简单应用
- NEST.net Client For Elasticsearch简单应用
- Elasticsearch .Net Client NEST 多条件查询示例
- NEST.net Client For Elasticsearch简单应用
- Nest .net client 使用简要说明
- ELK研究(一):elasticsearch java api接口操作ES集群 ---TransportClient的使用介绍 bulk批量提交数据
- Elasticsearch JDBC的使用-MySQL 数据源导入和增量索引、更新
- Elasticsearch JDBC的使用-MySQL 数据源导入和增量索引、更新
- .NET 分布式 搜索 elasticsearch.net NEST
- Elasticsearch.Net使用(一)【入门篇】
- ELK研究(一):elasticsearch java api接口操作ES集群 ---TransportClient的使用介绍 bulk批量提交数据
- elasticsearch.net search入门使用指南中文版(翻译)
- Elasticsearch.Net使用入门教程(1)
- Elasticsearch JDBC的使用-MySQL 数据源导入和增量索引、更新
- 《连载 | 物联网框架ServerSuperIO教程》- 18.集成OPC Client,及使用步骤。附:3.5 发布与更新说明。