Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
a client written in .net,won‘t maintenanced any more
C#
tree: b50b14fc22

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
BenchmarkTests
ElasticSearch.Client
ElasticSearch.DataManager
ElasticSearch.Tests
libs
.gitignore
ElasticSearch.Client.sln
ElasticSearch.DataManager.sln
README.textile

README.textile

ElasticSearch.NET Client

License

Apache2

Requirements

version 0.16.0 or upper
thrift plugin enabled (non framed)

Features

Thrift supported
ConnectionPool Supported
Multi-Cluster Supported

Sample Project

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

Tutorial

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


<?xml version="1.0" encoding="utf-8"?>
<ElasticSearchConfig>  
  <Clusters>
    <Cluster Name="Prod">
      <TransportType>Thrift</TransportType>
      <ThriftNodes>
        <Node Host="127.0.0.1" Port="9500" Enabled="true" IsFramed="false" >         
        </Node>
      </ThriftNodes>      
    </Cluster>
    <Cluster Name="localhost">
      <TransportType>Http</TransportType>
      <HttpNodes>
        <Node Host="localhost" Port="9200" Enabled="true"  >          
        </Node>
      </HttpNodes>      
    </Cluster>
  </Clusters>  
</ElasticSearchConfig>

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!

Something went wrong with that request. Please try again.