Elasticsearch .net client NEST使用说明 2.x

    

Elasticsearch.Net与NEST是Elasticsearch为C#提供的一套客户端驱动,方便C#调用Elasticsearch服务接口。Elasticsearch.Net是较基层的对Elasticsearch服务接口请求响应的实现,NEST是在前者基础之上进行的封装。本文是针对NEST的使用的总结。

目录:

Elasticsearch.Net、NEST 交流群:523061899

  demo源码 https://github.com/huhangfei/NestDemos

引用

  1. Install-Package NEST

包含以下dll

  1. NEST.dll
  1. Elasticsearch.Net.dll  
  1. Newtonsoft.Json.dll

概念

存储结构:

Elasticsearch中,文档(Document)归属于一种类型(type),而这些类型存在于索引(index).

类比传统关系型数据库:

  1. Relational DB -> Databases -> Tables -> Rows -> Columns
  2. Elasticsearch -> Indices -> Types -> Documents -> Fields

距离单位:

  • mm (毫米)

  • cm (厘米)

  • m (米)

  • km (千米)

  • in (英寸)

  • ft (英尺)

  • yd (码)

  • mi (英里)

  • nmi or NM (海里)

日期单位:

  • y (year)
  • M (month)
  • w (week)
  • d (day)
  • h (hour)
  • m (minute)
  • s (second)
  • ms (milliseconds)

客户端语法

链式lambda 表达式( powerful query DSL

  1. s => s
  2. .Query(q => q
  3. .Term(p => p.Name, "elasticsearch")
  4. )

对象初始化语法

  1. var searchRequest = new SearchRequest<VendorPriceInfo>
  2. {
  3. Query = new TermQuery
  4. {
  5. Field = "name",
  6. Value = "elasticsearch"
  7. }
  8. };

Connection链接

  1. //单node
  2. Var node = new Uri(“……”);
  3. var settings = new ConnectionSettings(node);
  4.  
  5. //多uri
  6. Var uris = new Uri [] {
  7. new Uri(“……”),
  8. new Uri(“……”)
  9. };
  10. //多node
  11. Var nodes = new Node [] {
  12. new Node (new Uri(“……”)),
  13. new Node (new Uri(“……”))
  14. };
  15.  
  16. var pool = new StaticConnectionPool(nodes);
  1. var pool = new StaticConnectionPool(uris);
  1. var settings = new ConnectionSettings(pool);
    var client = new ElasticClient(settings);

连接池类型:

  1. //对单节点请求
  2. IConnectionPool pool = new SingleNodeConnectionPool(urls.FirstOrDefault());
  3.  
  4. //请求时随机请求各个正常节点,不请求异常节点,异常节点恢复后会重新被请求
  5. IConnectionPool pool = new StaticConnectionPool(urls);
  6.  
  7. IConnectionPool pool = new SniffingConnectionPool(urls);
  8. //false.创建客户端时,随机选择一个节点作为客户端的请求对象,该节点异常后不会切换其它节点
  9. //true,请求时随机请求各个正常节点,不请求异常节点,但异常节点恢复后不会重新被请求
  10. pool.SniffedOnStartup = true;
  11.  
  12. //创建客户端时,选择第一个节点作为请求主节点,该节点异常后会切换其它节点,待主节点恢复后会自动切换回来
  13. IConnectionPool pool = new StickyConnectionPool(urls);

索引选择

方式1:

  1. var settings = new ConnectionSettings().DefaultIndex("defaultindex");

方式2:

  1. var settings = new ConnectionSettings().MapDefaultTypeIndices(m => m.Add(typeof(Project), "projects") );

方式3:

  1. client.Search<VendorPriceInfo>(s => s.Index("test-index"));
  2.  
  3. client.Index(data,o=>o.Index("test-index"));

优先级:方式3  > 方式2  > 方式1

索引

索引唯一Id:

1)  默认以“Id”字段值作为索引唯一Id值,无“Id”属性,Es自动生成唯一Id值,添加数据时统一类型数据唯一ID已存在相等值,将只做更新处理。

注:自动生成的ID22个字符长,URL-safe, Base64-encoded string universally unique identifiers, 或者叫UUIDs

2)  标记唯一Id值

  1. [ElasticsearchType(IdProperty = "priceID")]
  2. public class VendorPriceInfo
  3. {
  4. public Int64 priceID { get; set; }
  5. public int oldID { get; set; }
  6. public int source { get; set; }
  7. }

3)  索引时指定

  1. client.Index(data, o => o.Id(data.vendorName));

优先级: 3) > 2) > 1)

索引类型:

1)  默认类型为索引数据的类名(自动转换为全小写)

2)  标记类型

  1. [ElasticsearchType(Name = "datatype")]
  2. public class VendorPriceInfo
  3. {
  4. public Int64 priceID { get; set; }
  5. public int oldID { get; set; }
  6. public int source { get; set; }
  7. }

3)  索引时指定

  1. client.Index(data, o => o.Type(new TypeName() { Name = "datatype", Type = typeof(VendorPriceInfo) }));

  2. client.Index(data, o => o.Type<MyClass>());//使用 2)标记的类型

优先级:3> 2) > 1)

创建:

  1. client.CreateIndex("test2");
  2. //基本配置
  3. IIndexState indexState=new IndexState()
  4. {
  5. Settings = new IndexSettings()
  6. {
  7. NumberOfReplicas = ,//副本数
  8. NumberOfShards = //分片数
  9. }
  10. };
  11. client.CreateIndex("test2", p => p.InitializeUsing(indexState));
  12.  
  13. //创建并Mapping
  14. client.CreateIndex("test-index3", p => p.InitializeUsing(indexState).Mappings(m => m.Map<VendorPriceInfo>(mp => mp.AutoMap())));

注:索引名称必须小写

判断:

  1. client.IndexExists("test2");

删除:

  1. client.DeleteIndex("test2");

Open/Close:

  1. client.OpenIndex("index");
  2.  
  3. client.CloseIndex("index");

映射

概念:

每个类型拥有自己的映射(mapping)或者模式定义(schema definition)。一个映射定义了字段类型,每个字段的数据类型,以及字段被Elasticsearch处理的方式。映射还用于设置关联到类型上的元数据。

获取映射

  1. var resule = client.GetMapping<VendorPriceInfo>();

特性

  1. /// <summary>
  2. /// VendorPrice 实体
  3. /// </summary>
  4. [ElasticsearchType(IdProperty = "priceID", Name = "VendorPriceInfo")]
  5. public class VendorPriceInfo
  6. {
  7. [Number(NumberType.Long)]
  8. public Int64 priceID { get; set; }
  9. [Date(Format = "mmddyyyy")]
  10. public DateTime modifyTime { get; set; }
  11. /// <summary>
  12. /// 如果string 类型的字段不需要被分析器拆分,要作为一个正体进行查询,需标记此声明,否则索引的值将被分析器拆分
  13. /// </summary>
  14. [String(Index = FieldIndexOption.NotAnalyzed)]
  15. public string pvc_Name { get; set; }
  16. /// <summary>
  17. /// 设置索引时字段的名称
  18. /// </summary>
  19. [String(Name = "PvcDesc")]
  20. public string pvc_Desc { get; set; }
  21. /// <summary>
  22. /// 如需使用坐标点类型需添加坐标点特性,在maping时会自动映射类型
  23. /// </summary>
  24. [GeoPoint(Name = "ZuoBiao",LatLon = true)]
  25. public GeoLocation Location { get; set; }
  26. }

映射

  1. //根据对象类型自动映射
  2. var result= client.Map<VendorPriceInfo>(m => m.AutoMap());
  3. //手动指定
  4. var result1 = client.Map<VendorPriceInfo>(m => m.Properties(p => p
  5. .GeoPoint(gp => gp.Name(n => n.Location)// 坐标点类型
  6. .Fielddata(fd => fd
  7. .Format(GeoPointFielddataFormat.Compressed)//格式 array doc_values compressed disabled
  8. .Precision(new Distance(, DistanceUnit.Meters)) //精确度
  9. ))
  10. .String(s => s.Name(n => n.b_id))//string 类型
  11. ));
  12. //在原有字段下新增字段(用于存储不同格式的数据,查询方法查看SearchBaseDemo)
  13. //eg:在 vendorName 下添加无需分析器分析的值 temp
  14. var result2 = client.Map<VendorPriceInfo>(
  15. m => m
  16. .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的处理过程如下:
    1.       从旧文档中检索JSON
    2.       修改它
    3.       删除旧文档
    4.       索引新文档

所以我们也可以使用Index来更新已存在文档,只需对应文档的唯一id

添加索引数据:

添加单条数据
  1. var data = new VendorPriceInfo() { vendorName = "测试"};
  2. client.Index(data);
添加多条数据
  1. var datas = new List<VendorPriceInfo> {
  2. new VendorPriceInfo(){priceID = ,vendorName = "test1"},
  3. new VendorPriceInfo(){priceID = ,vendorName = "test2"}};
  4. client.IndexMany(datas);

删除数据:

单条数据
  1. DocumentPath<VendorPriceInfo> deletePath=new DocumentPath<VendorPriceInfo>();
  2. client.Delete(deletePath);
  3.  

  4. IDeleteRequest request = new DeleteRequest("test3", "vendorpriceinfo", );
  5. client.Delete(request);
注:删除时根据唯一id删除
集合数据
  1. Indices indices = "test-1";
  2. Types types = "vendorpriceinfo";
  3. //批量删除 需要es安装 delete-by-query插件
  4. var result = client.DeleteByQuery<VendorPriceInfo>(indices, types,
  5. dq =>
  6. dq.Query(
  7. q =>
  8. q.TermRange(tr => tr.Field(fd => fd.priceID).GreaterThanOrEquals("").LessThanOrEquals("")))
  9. );

更新数据:

更新所有字段
  1. DocumentPath<VendorPriceInfo> deletePath=new DocumentPath<VendorPriceInfo>();
  2. Var response=client.Update(deletePath,(p)=>p.Doc(new VendorPriceInfo(){vendorName = "test2update..."}));
  3. //或
  4. IUpdateRequest<VendorPriceInfo, VendorPriceInfo> request = new UpdateRequest<VendorPriceInfo, VendorPriceInfo>(deletePath)
  5. {
  6. Doc = new VendorPriceInfo()
  7. {
  8. priceID = ,
  9. vendorName = "test4update........"
  10. }
  11. };
  12. var response = client.Update<VendorPriceInfo, VendorPriceInfo>(request);
更新部分字段
  1. IUpdateRequest<VendorPriceInfo, VendorPriceInfoP> request = new UpdateRequest<VendorPriceInfo, VendorPriceInfoP>(deletePath)
  2. {
  3. Doc = new VendorPriceInfoP()
  4. {
  5. priceID = ,
  6. vendorName = "test4update........"
  7. }
  8.  
  9. };
  10. var response = client.Update(request); 
更新部分字段
  1. IUpdateRequest<VendorPriceInfo, object> request = new UpdateRequest<VendorPriceInfo, object>(deletePath)
  2. {
  3. Doc = new
  4. {
  5. priceID = ,
  6. vendorName = " test4update........"
  7. }
  8. };
  9. var response = client.Update(request);
  10.  
  11. //或
  12. client.Update<VendorPriceInfo, object>(deletePath, upt => upt.Doc(new { vendorName = "ptptptptp" }));

注:更新时根据唯一id更新

获取数据:

  1. var response = client.Get(new DocumentPath<VendorPriceInfo>());
  2. //或
  3. var response =
  4. client.Get(new DocumentPath<VendorPriceInfo>(),pd=>pd.Index("test4").Type("v2"));
  5.  
  6. //多个
  7. var response = client.MultiGet(m => m.GetMany<VendorPriceInfo>(new List<long> { , , , })); 

注:获取时根据唯一id获取

搜索:

说明

基本搜索

  1. var result = client.Search<VendorPriceInfo>(
  2. s => s
  3. .Explain() //参数可以提供查询的更多详情。
  4. .FielddataFields(fs => fs //对指定字段进行分析
  5. .Field(p => p.vendorFullName)
  6. .Field(p => p.cbName)
  7. )
  8. .From() //跳过的数据个数
  9. .Size() //返回数据个数
  10. .Query(q =>
  11. q.Term(p => p.vendorID, ) // 主要用于精确匹配哪些值,比如数字,日期,布尔值或 not_analyzed的字符串(未经分析的文本数据类型):
  12. &&
  13. q.Term(p => p.vendorName.Suffix("temp"), "姓名") //用于自定义属性的查询 (定义方法查看MappingDemo)
  14. &&
  15. q.Bool( //bool 查询
  16. b => b
  17. .Must(mt => mt //所有分句必须全部匹配,与 AND 相同
  18. .TermRange(p => p.Field(f => f.priceID).GreaterThan("").LessThan(""))) //指定范围查找
  19. .Should(sd => sd //至少有一个分句匹配,与 OR 相同
  20. .Term(p => p.priceID, ),
  21. sd => sd.Terms(t => t.Field(fd => fd.priceID).Terms(new[] {, , })),//多值
  22. //||
  23. //sd.Term(p => p.priceID, 1001)
  24. //||
  25. //sd.Term(p => p.priceID, 1005)
  26. sd => sd.TermRange(tr => tr.GreaterThan("").LessThan("").Field(f => f.vendorPrice))
  27. )
  28. .MustNot(mn => mn//所有分句都必须不匹配,与 NOT 相同
  29. .Term(p => p.priceID, )
  30. ,
  31. mn => mn.Bool(//bool 过滤 ,bool 查询与 bool 过滤相似,用于合并多个查询子句。不同的是,bool 过滤可以直接给出是否匹配成功, 而bool 查询要计算每一个查询子句的 _score (相关性分值)。
  32. bb=>bb.Must(mt=>mt
  33. .Match(mc=>mc.Field(fd=>fd.carName).Query("至尊"))
  34. ))
  35. )
  36. )
  37.  
  38. )//查询条件
  39. .Sort(st => st.Ascending(asc => asc.vendorPrice))//排序
  40. .Source(sc => sc.Include(ic => ic
  41. .Fields(
  42. fd => fd.vendorName,
  43. fd => fd.vendorID,
  44. fd => fd.priceID,
  45. fd => fd.vendorPrice))) //返回特定的字段
  46. );
  47. //TResult
  48. var result1 = client.Search<VendorPriceInfo, VendorPriceInfoP>(s => s.Query(
  49. q => q.MatchAll()
  50. )
  51. .Size()
  52. );

  1. var result = client.Search<VendorPriceInfo>(new SearchRequest()
  2. {
  3. Sort =new List<ISort>
  4. {
  5. new SortField { Field = "vendorPrice", Order = SortOrder.Ascending }
  6. },
  7. Size = ,
  8. From = ,
  9. Query = new TermQuery()
  10. {
  11. Field = "priceID",
  12. Value =
  13. }
  14. ||
  15. new TermQuery(
  16. {
  17. Field = "priceID",
  18. Value =
  19. }
  20. });

分页

  1. //分页最大限制(from+size<=10000)
    int pageSize = ;
  2. int pageIndex = ;
  3. var result = client.Search<VendorPriceInfo>(s => s.Query(q => q
  4. .MatchAll())
  5. .Size(pageSize)
  6. .From((pageIndex - ) * pageSize)
  7. .Sort(st => st.Descending(d => d.priceID)));

扫描和滚屏

  1. string scrollid = "";
  2. var result = client.Search<VendorPriceInfo>(s => s.Query(q => q.MatchAll())
  3. .Size()
  4. .SearchType(SearchType.Scan)
  5. .Scroll("1m"));//scrollid过期时间
  6. //得到滚动扫描的id
  7. scrollid = result.ScrollId;
  8.  
  9. //执行滚动扫描得到数据 返回数据量是 result.Shards.Successful*size(查询成功的分片数*size)
  10. result = client.Scroll<VendorPriceInfo>("1m", scrollid);
  11. //得到新的id
  12. scrollid = result.ScrollId;

查询条件设置加权

  1. // 在原分值基础上 设置不同匹配的加成值 具体算法为lucene内部算法
    var result = client.Search<VendorPriceInfo>(s => s
  2. .Query(q =>
  3. q.Term(t => t
  4. .Field(f => f.cityID).Value().Boost())
  5. ||
  6. q.Term(t => t
  7. .Field(f => f.pvcId).Value().Boost())
  8. )
  9. .Size()
  10. .Sort(st => st.Descending(SortSpecialField.Score))
  11. );

得分控制

  1. //使用functionscore计算得分
    var result1 = client.Search<VendorPriceInfo>(s => s
  2. .Query(q=>q.FunctionScore(f=>f
                  //查询区
  3. .Query(qq => qq.Term(t => t
  4. .Field(fd => fd.cityID).Value())
  5. ||
  6. qq.Term(t => t
  7. .Field(fd => fd.pvcId).Value())
  8. )
  9. .Boost(1.0) //functionscore 对分值影响
  10. .BoostMode(FunctionBoostMode.Replace)//计算boost 模式 ;Replace为替换
  11. .ScoreMode(FunctionScoreMode.Sum) //计算score 模式;Sum为累加
                  //逻辑区
  12. .Functions(fun=>fun
  13. .Weight(w => w.Weight().Filter(ft => ft
  14. .Term(t => t
  15. .Field(fd => fd.cityID).Value())))//匹配cityid +2
  16. .Weight(w => w.Weight().Filter(ft => ft
  17. .Term(t => t
  18. .Field(fd => fd.pvcId).Value())))//匹配pvcid +1
  19. )
  20. )
  21. )
  22. .Size()
  23. .Sort(st => st.Descending(SortSpecialField.Score).Descending(dsc=>dsc.priceID))
  24. );
    //结果中 cityid=2108,得分=2; pvcid=2103 ,得分=1 ,两者都满足的,得分=3
  1.  
  1.  

查询字符串-简单的检索

  1. var result = client.Search<VendorPriceInfo>(s => s
  2. .Query(q => q.QueryString(m => m.Fields(fd=>fd.Field(fdd=>fdd.carName).Field(fdd=>fdd.carGearBox))
  3. .Query("手自一体")
  4. )
  5. )
  6. .From()
  7. .Size()
  8. );

全文检索-关键词搜索

  1. var result=client.Search<VendorPriceInfo>(s=>s
  2. .Query(q=>q
  3. .Match(m=>m.Field(f=>f.carName)
  4. .Query("尊贵型")
  5. )
  6. )
  7. .From()
  8. .Size()
  9. );
  10. //多字段匹配
  11. var result1 = client.Search<VendorPriceInfo>(s => s
  12. .Query(q => q
  13. .MultiMatch(m => m.Fields(fd=>fd.Fields(f=>f.carName,f=>f.carGearBox))
  14. .Query("尊贵型")
  15. )
  16. )
  17. .From()
  18. .Size()
  19. );

全文搜索-短语搜索

  1. var result = client.Search<VendorPriceInfo>(s => s
  2. .Query(q => q.MatchPhrase(m => m.Field(f => f.carName)
  3. .Query("尊贵型")
  4. )
  5. )
  6. .From()
  7. .Size()
  8. );

坐标点搜索-根据坐标点及距离搜索

  1. const double lat = 39.8694890000;
  2. const double lon = 116.4206470000;
  3. const double distance = 2000.0;
  4.  
  5. //
  6. var result = client.Search<VendorPriceInfo>(s => s
  7. .Query(q => q
  8. .Bool(b => b.Must(m => m
  9. .GeoDistance(gd => gd
  10. .Location(lat, lon)
  11. .Distance(distance, DistanceUnit.Meters)
  12. .Field(fd => fd.Location)
  13. ))
  14. )
  15. )
  16. .From()
  17. .Size()
  18. );
  19.  
  20. //
  21. var location = new GeoLocation(lat, lon);
  22. var distancei = new Distance(distance, DistanceUnit.Meters);
  23. var result1 = client.Search<VendorPriceInfo>(s => s
  24. .Query(q => q
  25. .Bool(b => b.Must(m => m
  26. .Exists(e => e.Field(fd => fd.Location))
  27. )
  28. )
  29. &&
  30. q.GeoDistance(gd => gd
  31. .Location(location)
  32. .Distance(distancei)
  33. .Field(fd => fd.Location)
  34. )
  35. )
  36. .From()
  37. .Size()
  38. );
  39.  
  40. //
  41. var result2 = client.Search<VendorPriceInfo>(s => s
  42. .Query(q => q
  43. .Bool(b=>b
  44. .Must(m=>m.MatchAll())
  45. .Filter(f=>f
  46. .GeoDistance(g => g
  47. .Name("named_query")
  48. .Field(p => p.Location)
  49. .DistanceType(GeoDistanceType.Arc)
  50. .Location(lat,lon)
  51. .Distance("2000.0m")
  52. )
  53. )
  54. )
  55. )
  56. .From()
  57. .Size()
  58. );

聚合

聚合-基本

  1. var result = client.Search<VendorPriceInfo>(s => s
  2. .From()
  3. .Size()
  4. .Aggregations(ag=>ag
  5. .ValueCount("Count", vc => vc.Field(fd => fd.vendorPrice))//总数
  6. .Sum("vendorPrice_Sum", su => su.Field(fd => fd.vendorPrice))//求和
  7. .Max("vendorPrice_Max", m => m.Field(fd => fd.vendorPrice))//最大值
  8. .Min("vendorPrice_Min", m => m.Field(fd => fd.vendorPrice))//最小值
  9. .Average("vendorPrice_Avg", avg => avg.Field(fd => fd.vendorPrice))//平均值
  10. .Terms("vendorID_group", t => t.Field(fd => fd.vendorID).Size())//分组
  11. )
  12. );

聚合-分组

  1. //每个经销商 的平均报价
  2. var result = client.Search<VendorPriceInfo>(s => s
  3. .Size()
  4. .Aggregations(ag => ag
  5. .Terms("vendorID_group", t => t
  6. .Field(fd => fd.vendorID)
  7. .Size()
  8. .Aggregations(agg => agg.Average("vendorID_Price_Avg", av => av.Field(fd => fd.vendorPrice)))
  9. )//分组
  10. .Cardinality("vendorID_group_count", dy => dy.Field(fd => fd.vendorID))//分组数量
  11. .ValueCount("Count", c => c.Field(fd => fd.vendorID))//总记录数
  12. )
  13. );

聚合-分组-聚合..

  1. //每个经销商下 每个品牌 的平均报价
  2. var result = client.Search<VendorPriceInfo>(s => s
  3. .Size()
  4. .Aggregations(ag => ag
  5. .Terms("vendorID_group", //vendorID 分组
  6. t => t.Field(fd => fd.vendorID)
  7. .Size()
  8. .Aggregations(agg => agg
  9. .Terms("vendorID_cbID_group", //cbID分组
  10. tt => tt.Field(fd => fd.cbID)
  11. .Size()
  12. .Aggregations(aggg => aggg
  13. .Average("vendorID_cbID_Price_Avg", av => av.Field(fd => fd.vendorPrice))//Price avg
  14. .Max("vendorID_cbID_Price_Max", m => m.Field(fd => fd.vendorPrice))//Price max
  15. .Min("vendorID_cbID_Price_Min", m => m.Field(fd => fd.vendorPrice))//Price min
  16. .ValueCount("vendorID_cbID_Count", m => m.Field(fd => fd.cbID))//该经销商对该品牌 报价数 count
  17. )
  18. )
  19. .Cardinality("vendorID_cbID_group_count", dy => dy.Field(fd => fd.cbID))//分组数量
  20. .ValueCount("vendorID_Count", c => c.Field(fd => fd.vendorID))//该经销商的报价数
  21. )
  22. )
  23. .Cardinality("vendorID_group_count",dy=>dy.Field(fd=>fd.vendorID))//分组数量
  24. .ValueCount("Count",c=>c.Field(fd=>fd.priceID))//总记录数
  25. ) //分组
  26. );

官网文档:

https://www.elastic.co/guide/en/elasticsearch/client/net-api/2.x/introduction.html

Elasticsearch.Net、NEST 交流群:523061899

Elasticsearch .Net Client NEST使用说明 2.x的更多相关文章

  1. Elasticsearch .net client NEST使用说明 2.x -更新版

    Elasticsearch .net client NEST使用说明 目录: Elasticsearch .net client NEST 5.x 使用总结 elasticsearch_.net_cl ...

  2. (转)Elasticsearch .net client NEST使用说明 2.x

    Elasticsearch.Net与NEST是Elasticsearch为C#提供的一套客户端驱动,方便C#调用Elasticsearch服务接口.Elasticsearch.Net是较基层的对Ela ...

  3. Elasticsearch .net client NEST 5.x 使用总结

    目录: Elasticsearch .net client NEST 5.x 使用总结 elasticsearch_.net_client_nest2.x_到_5.x常用方法属性差异 Elastics ...

  4. Elasticsearch .Net Client NEST 多条件查询示例

    Elasticsearch .Net Client NEST 多条件查询示例 /// <summary> /// 多条件搜索例子 /// </summary> public c ...

  5. Elasticsearch .Net Client NEST 索引DataSet数据

    NEST 索引DataSet数据,先序列化然后转成dynamic 类型进行索引: /// <summary> /// 索引dataset /// </summary> /// ...

  6. Elasticsearch .net client NEST 空字符/null值查询

    null值查询 当某个字段值为null时,其实在es里该条数据是没有这个字段的.查询时检测包含不包含该字段就行. /// <summary> /// null 值查询 /// 当数据为Nu ...

  7. elasticsearch系列七:ES Java客户端-Elasticsearch Java client(ES Client 简介、Java REST Client、Java Client、Spring Data Elasticsearch)

    一.ES Client 简介 1. ES是一个服务,采用C/S结构 2. 回顾 ES的架构 3. ES支持的客户端连接方式 3.1 REST API ,端口 9200 这种连接方式对应于架构图中的RE ...

  8. Elasticsearch Java Client连接池

    按照Elasticsearch API,在Java端使用是ES服务需要创建Java Client,但是每一次连接都实例化一个client,对系统的消耗很大,即使在使用完毕之后将client close ...

  9. Elasticsearch Java client(ES Client 简介、Java REST Client、Java Client、Spring Data Elasticsearch)

    elasticsearch系列七:ES Java客户端-Elasticsearch Java client(ES Client 简介.Java REST Client.Java Client.Spri ...

随机推荐

  1. Android之单复选框及Spinner实现二级联动

    一.基础学习 1.图形学真的很神奇啊....查了些资料做出了3D云标签,哈哈...其实直接拿来用的,我们要效仿鲁迅先生的拿来主义,嘿嘿~~3D标签云就是做一个球面,然后再球面上取均匀分布的点,把点坐标 ...

  2. 形形色色Node工程Angular2

    最近项目要用的 一些无关紧要的文件夹, demo是一些示例, dist是webpack打包后发布的代码,server是用node启动服务,typings和tsconfig是一些ts配置. npm in ...

  3. USB做Host的OTG原理

    在介绍USBOTG的基础上,着重介绍Maxim公司的MAX3301E型USBOTG电路的特点.内部结构和工作原理. 1 引言 随着USB2.0版本的发布,USB越来越流行,已经成为一种标准接口.现在, ...

  4. Android 获取图片资源的4种方式

    1. 图片放在sdcard中 Bitmap imageBitmap = BitmapFactory.decodeFile(path) (path 是图片的路径,跟目录是/sdcard) 2. 图片在项 ...

  5. 【HDOJ】4513 吉哥系列故事——完美队形II

    这题目上学期就看了,不过最近发现可以用马拉车来解,而且还是基本算法. 稍微对回文串成立条件变形一下即可. /* 4513 */ #include <iostream> #include & ...

  6. JavaScript日期时间操作

    <script> var d=new Date();//当前时间 alert(d); var d1=new Date(1992,5,19);//定义一个时间,月份要加1; alert(d1 ...

  7. [C# 网络编程系列]专题六:UDP编程

    转自:http://www.cnblogs.com/zhili/archive/2012/09/01/2659167.html 引用: 前一个专题简单介绍了TCP编程的一些知识,UDP与TCP地位相当 ...

  8. HDU 5938 Four Operations 【贪心】(2016年中国大学生程序设计竞赛(杭州))

    Four Operations Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  9. wxWidgets一个界面与数据分离的简单例子

    /*************************************************************** * Name: MyApp.h * Purpose: Defines ...

  10. sublime text 2 运行 python时返回EOFError: EOF when reading a line错误

    其主要原因是sublime text 2中python没有与 stdin(标准输入)连接所致,解决方法也很简单,那就是安装sublimeREPL插件,然后 Tools->sublimerepl- ...