Skip to content
This repository has been archived by the owner on Jul 18, 2018. It is now read-only.

medcl/ElasticSearch.Net

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

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!

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages