I. ES installation-related
1.elasticsearch Installation
Run Http://localhost:9200/
2.head plug-in
3.bigdesk plug-in installation
(Installation details Baidu: Windows Elasticsearch installation, detailed content)
Two. Es plugin-related
Www.searchtech.pro/elasticsearch-plugins (es plugin Daquan)
(IK project)
(es plug-in monitoring node status, you can also debug your ES query)
(2.1.1 + 1.6ik and pinyin and other word breakers integrated well)
(head-like plug-in)
Www.elastic.co/downloads/marvel (monitor ES health status)
Konf plug-in (said to look at cluster load)
Three. ES C # Client sample
1. Package download Elasticsearch.net,nest components.
The nest component relies on downloading the Elasticsearch component.
Working with Documents:
NOTE:. NET uses a relatively small number of ES, ES version updates are also very fast, many use also rely on their own. More communication, more sharing.
2. Create a connection Client
Public elasticclient getclient () { var node = new Uri ("http://192.168.17.54:9200"); var settings = new ConnectionSettings ( node, defaultindex: "My-application" ); return new elasticclient (settings); }
3. Create an index model (index structure)
[Elastictype (Idproperty = "Id", Name = "person")] public class person { [Elasticproperty (Name = "Id", Type = fieldtype.string, Index = fieldindexoption.notanalyzed)] public string Id {get; set;} public string Firstname {get; set;} public string Lastname {get; set;} Public string[] Chains {get; set;} [Elasticproperty (Name = "Content", Type = fieldtype.string, Index = fieldindexoption.analyzed, Analyzer = "Ik_max_word")] Public string Content {get; set;} }
Note: The model example provided by others, in more detail, can be downloaded as an attachment.
4. Index content (CREATE INDEX)
private void Btnindex_click (object sender, EventArgs e) {//var client = new Elasticsearchclient (); Index a document UNDER/MYINDEX/MYTYPE/1//var indexresponse = client. Index ("Myindex", "MyType", "1", new {Hello = "world"}); var client2 = getclient (); Client2. CreateIndex ("test"); Client2. Map<person> (c = c.mapfromattributes ()); ienumerable<person> persons = new List<person> {new person () { Id = "4", Firstname = "AAA",//boterhuis-040 Lastname = "Gusto-040", Chains = new string[]{"A", "B", "C"},}, new person () { Id = "5", Firstname = "sales@historichousehotels.com", Lastname = "T Boterhuis 1 ", Chains = new string[]{" A "," B "," C "}, }, new Person () {Id = "6", Firstname = "Aberd Een #110 ", Lastname =" sales@historichousehotels.com ", Chains = new string[]{" A "," B "," C "},}, new Person () {Id =" 7 ", Fi Rstname = "Aberdeen #110", Lastname = "T Boterhuis 2", Chains = new string[]{"A", "B "," C "},}, new Person () {Id =" 8 ", F Irstname = "Aberdeen #110", Lastname = "T Boterhuis 2", Chains = new string[]{"A", " B "," C "},},}; foreach (var p in persons) Client2. indexmany<person> (persons, "test"); }
5. Simple Search Example
var client = Getclient (); var rs = client. Search<person> (s = = S.index ("Test"). QueryString (This.textBox1.Text)); This.richTextBox1.Text = Jsonconvert.serializeobject (rs. Documents);
6. Index Updates
private void Btnupdate_click (object sender, EventArgs e) { var client2 = getclient (); Client2. Update<person, object> (u = u . Index ("Test") . Id (4) . Doc (New {id= "4", Firstname = "states"}) . Retryonconflict (3) . Refresh () ); var u1 = New Person () // { // Id = "4", // Firstname = "Boterhuis-040", //< C18/>lastname = "Gusto-040", // Chains = new string[]{"A", "B", "C"}, // }; var U2 = new Person () // { // Id = "4", // Firstname = "states", // Lastname = "Gusto-040", // Chains = new string[] {"A", "B", "C"}, // }; Client2. Update<person,person> (U1,U2). }
7. Index deletion
private void Btndelete_click (object sender, EventArgs e) { var client2 = getclient (); Client2. Deleteindex ("test"); Client2. Deleteindex ("My-application"); }
8. Summary
In the example code above, a simple application is sufficient. The others are highlighting and grouping. You can see the document.
four. ES cluster
ES is a cluster by default, simpler to configure than SOLR cloud, and easier to build. But more still have to be based on the business of their own cluster design or good time, a lot of energy. (Easy to get started, hard to use)
five. Es vs. SOLR
What the individual currently understands:
The original SOLR more information, now looks like es more information. SOLR is the official English pdf,es also in English.
The original SOLR also has Chinese books, now seems to have no. ES currently has several books, but the ES version is slightly older.
SOLR is slightly more difficult to get started with ES.
(N years ago, I used the SOLR, when there is no solrcloud;es yet out, then SOLR data more.) Individuals have also implemented their own SOLR cluster solution. Other features on the contrast, or Baidu, do not repeat. )
Six. If the ES client debug request
We recommend that you download a TCP interception tool such as Httpanalyzer. This can intercept the verification SDK out of the request connection, compare the data and books to see which parameters are wrong, debugging is very helpful.
Seven. ES appendix
Es term Description:
Cluster
Represents a cluster in which there are multiple nodes, one of which is the primary node. This master node can be elected. Note that the master-slave node is for the inside of the cluster. One of the concepts of ES is to center, literally understand that there is no central node, this is for the outside of the cluster, because the ES cluster from the outside, in a logical whole, you communicate with any one node and the entire ES cluster communication is equivalent.
Shards
Represents the Index Shard. Es can divide a complete index into multiple shards, and the benefit is that a large index can be split into multiple nodes. constitute a distributed search. The number of shards can only be specified before the index is created, and cannot be changed after the index is created.
Replicas
Represents a copy of an index, ES can set a copy of multiple indexes. The role of the replica, one is to improve the system's fault tolerance, when a node of a shard corruption or loss can be recovered from the replica, the second is to improve the efficiency of the query es, ES will automatically load balance search requests.
Recovery
Represents data recovery or redistribution of data, ES when a node joins or exits the index shards are redistributed based on the load of the machine, and data recovery occurs when the node is restarted.
River
Represents a data source for ES and is also a way to synchronize data to ES with other storage methods (such as databases). It is an ES service that exists in plug-in mode, by reading the data in the river and indexing it into ES, the official river is couchdb, RABBITMQ, Twitter, Wikipedia.
Gateway
Represents how the ES index snapshot is stored. ES defaults to storing the index in memory and then persisting to the local hard disk when the memory is full. The Gateway stores the index snapshot, and when the ES cluster is shut down and restarted, the index backup data is read from the gateway. ES supports multiple types of gateway, with local file system (default), Distributed File System, Hadoop HDFs and Amazon's S3 cloud storage service.
Discovery.zen
Represents the automatic discovery node mechanism for ES. ES is a peer-based system that first searches for existing nodes by broadcasting, and then communicates between nodes through multicast protocols, while also supporting point-to-point interactions.
Transport
Represents how es internal nodes or clusters interact with the client. The default internal is to use the TCP protocol to interact, while it supports the HTTP protocol (JSON format), thrift, servlet, memcached, ZEROMQ and other transport protocols (through plug-in mode integration).