ElasticSearch.Net icon indicating copy to clipboard operation
ElasticSearch.Net copied to clipboard

a client written in .net, won‘t maintenance any more

h1. ElasticSearch.NET Client

h2. License

Apache2

h2. Requirements

version 0.16.0 or upper thrift plugin enabled (non framed)

h2. Features

Thrift supported ConnectionPool Supported Multi-Cluster Supported

h2. Sample Project

ElasticSearch.DataManager index relocate:reindex data from exist index(_source enabled) index manage:bulk delete,quick data sample,search etc.

h2. Tutorial

h3. How to use

thrift config

in order to use thrift,you have to config to support cluster first download the thrift-plugin second edit the config/elasticsearch.yml with below:

  thrift.port : 9500
  thrift.protocol : 'binary'

client config

edit the cluster config file:ElasticSearch.config you can specify the cluster,and nodes,and also config the connection pool,and you can even specify the socket settings here is simple example



  
  
    
      Thrift
      
                 
        
            
    
    
      Http
      
                  
        
            
    
    


and now rock with elasticsearch.net

var client = new ElasticSearchClient("localhost");


CreateIndex:
      client.CreateIndex("index", new IndexSetting(5, 1));

ModifyIndex:
      client.ModifyIndex(index, new IndexSetting(10, 2));

DeleteIndex:
      client.DeleteIndex("index");

CreateMapping:
      var index = "index_operate" + Guid.NewGuid().ToString();
			StringFieldSetting stringFieldSetting = new StringFieldSetting() { Analyzer = "standard", Type = "string", NullValue = "mystr" };

			TypeSetting typeSetting = new TypeSetting("custom_type");
			typeSetting.AddFieldSetting("medcl", stringFieldSetting);

			var typeSetting2 = new TypeSetting("hell_type1");
			var numfield = new NumberFieldSetting() { Store = Store.yes, NullValue = 0.00 };
			typeSetting2.AddFieldSetting("name", numfield);

			var result = client.PutMapping(index, typeSetting);



Index:
      client.Index("testindex", "testtype", "testkey", "{\"a\":\"b\"}");
Search:
      client.Search("testindex", "testtype", "_id:testkey");
Delete:
      client.Delete("testindex", "testtype", "testkey");
Get:
      client.Get("testindex", "testtype", "testkey");

check my tests for more example!