


Detailed explanation of getting started with .net Elasticsearch examples
1. 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, details are available)
2. es plug-in related
www.searchtech.pro/elasticsearch-plugins (es plug-in collection)
(ik project)
(ES plug-in monitors node status and can also debug your ES query)
(2.1.1 + 1.6ik There is also Pinyin integrated with other tokenizers)
(plug-in similar to head)
www.elastic.co/downloads/marvel (monitoring ES health status)
konf plug-in (it is said that it can monitor the cluster Load)
三.es C# client example
1. Package download elasticsearch.net, nest component.
The nest component will depend on downloading the elasticsearch component.
Usage documentation:
Remarks: Relatively few people use es in .net, and the es version is updated very quickly. Many uses are based on their own guessing. Communicate more and share more.
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: For more detailed model examples provided by others, you can download the 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 = "Aberdeen #110", Lastname = "sales@historichousehotels.com", Chains = new string[]{ "a","b","c" }, }, new Person() { Id = "7", Firstname = "Aberdeen #110", Lastname = "t Boterhuis 2", Chains = new string[]{ "a","b","c" }, }, new Person() { Id = "8", Firstname = "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 update
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 = "United States" }) .RetryOnConflict(3) .Refresh() ); //var u1 = new Person() // { // Id = "4", // Firstname = "Boterhuis-040", // Lastname = "Gusto-040", // Chains = new string[]{ "a","b","c" }, // }; //var u2 = new Person() // { // Id = "4", // Firstname = "United 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. 总结
以上示例代码,简单的应用已经足够用。其他的就是高亮和分组。可以看文档。
四. es 集群
es 默认是一个集群,相对solr云来说配置更简单,搭建更方便些。但是更多还是要根据业务进行自己的集群设计还是好费很多时间,很多精力。(上手容易,用好难)
五. es 与solr 对比
个人目前了解的:
原来solr资料比较多,现在貌似es的资料更多一点。solr是官方英文pdf,es也是英文的。
原来solr还有中文书籍,现在貌似没有了。es 目前还有几本书籍,但是讲的es版本略有老旧。
solr上手相对es略微难些。
(n年前,我用的是solr,那时候还没有solrcloud;es还没有出来,那时候solr资料反而多。个人也实现了自己的solr集群方案。其他的功能上的对比,还是百度,不重复。)
六. 如果es客户端调试请求
建议下载HTTPAnalyzer之类的tcp拦截工具。这样可以拦截验证sdk出来的请求连接,对比资料和书籍看下哪些参数写错了,对调试很有帮助。
七. es 附录
es术语介绍:
cluster:
代 表一个集群,集群中有多个节点,其中有一个为主节点。这个主节点是可以通过选举产生的。注意,主从节点是对于集群内部来说的。es的一个概念就是去中心 化,字面上理解就是无中心节点,这是对于集群外部来说的,因为从外部来看es集群,在逻辑上是个整体,你与任何一个节点的通信和与整个es集群通信是等价 的。
shards
代表索引分片。es可以把一个完整的索引分成多个分片,这样的好处是可以把一个大的索引拆分成多个,分布到不同的节点上。构成分布式搜索。分片的数量只能在索引创建前指定,并且索引创建后不能更改。
replicas
代表索引副本,es可以设置多个索引的副本。副本的作用,一是提高系统的容错性,当某个节点的某个分片损坏或丢失时可以从副本中恢复,二是提高es的查询效率,es会自动对搜索请求进行负载均衡。
recovery
代表数据恢复或叫数据重新分布,es在有节点加入或退出时会根据机器的负载对索引分片进行重新分配,挂掉的节点重新启动时也会进行数据恢复。
river
代表es的一个数据源,也是其他存储方式(如:数据库)同步数据到es的一个方法。它是以插件方式存在的一个es服务,通过读取river中的数据并把它索引到es中,官方的river有couchDB的,RabbitMQ的,Twitter的,Wikipedia的。
gateway
代 表es索引快照的存储方式。es默认是先把索引存放到内存中,当内存满了时再持久化到本地硬盘。gateway对索引快照进行存储,当这个es集群关闭再 重新启动时,就会从gateway中读取索引备份数据。es支持多种类型的gateway,有本地文件系统(默认),分布式文件系统,Hadoop的 HDFS和amazon的s3云存储服务。
discovery.zen
代表es的自动发现节点机制。es是一个基于p2p的系统,它先通过广播寻找存在的节点,再通过多播协议来进行节点之间的通信,同时也支持点对点的交互。
Transport
代表es内部节点或集群与客户端的交互方式。默认内部是使用tcp协议进行交互,同时它支持http协议(json格式)、thrift、servlet、memcached、zeroMQ等的传输协议(通过插件方式集成)。
The above is the detailed content of Detailed explanation of getting started with .net Elasticsearch examples. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











How to delete Xiaohongshu notes? Notes can be edited in the Xiaohongshu APP. Most users don’t know how to delete Xiaohongshu notes. Next, the editor brings users pictures and texts on how to delete Xiaohongshu notes. Tutorial, interested users come and take a look! Xiaohongshu usage tutorial How to delete Xiaohongshu notes 1. First open the Xiaohongshu APP and enter the main page, select [Me] in the lower right corner to enter the special area; 2. Then in the My area, click on the note page shown in the picture below , select the note you want to delete; 3. Enter the note page, click [three dots] in the upper right corner; 4. Finally, the function bar will expand at the bottom, click [Delete] to complete.

Diffusion can not only imitate better, but also "create". The diffusion model (DiffusionModel) is an image generation model. Compared with the well-known algorithms such as GAN and VAE in the field of AI, the diffusion model takes a different approach. Its main idea is a process of first adding noise to the image and then gradually denoising it. How to denoise and restore the original image is the core part of the algorithm. The final algorithm is able to generate an image from a random noisy image. In recent years, the phenomenal growth of generative AI has enabled many exciting applications in text-to-image generation, video generation, and more. The basic principle behind these generative tools is the concept of diffusion, a special sampling mechanism that overcomes the limitations of previous methods.

Kimi: In just one sentence, in just ten seconds, a PPT will be ready. PPT is so annoying! To hold a meeting, you need to have a PPT; to write a weekly report, you need to have a PPT; to make an investment, you need to show a PPT; even when you accuse someone of cheating, you have to send a PPT. College is more like studying a PPT major. You watch PPT in class and do PPT after class. Perhaps, when Dennis Austin invented PPT 37 years ago, he did not expect that one day PPT would become so widespread. Talking about our hard experience of making PPT brings tears to our eyes. "It took three months to make a PPT of more than 20 pages, and I revised it dozens of times. I felt like vomiting when I saw the PPT." "At my peak, I did five PPTs a day, and even my breathing was PPT." If you have an impromptu meeting, you should do it

As a Xiaohongshu user, we have all encountered the situation where published notes suddenly disappeared, which is undoubtedly confusing and worrying. In this case, what should we do? This article will focus on the topic of "What to do if the notes published by Xiaohongshu are missing" and give you a detailed answer. 1. What should I do if the notes published by Xiaohongshu are missing? First, don't panic. If you find that your notes are missing, staying calm is key and don't panic. This may be caused by platform system failure or operational errors. Checking release records is easy. Just open the Xiaohongshu App and click "Me" → "Publish" → "All Publications" to view your own publishing records. Here you can easily find previously published notes. 3.Repost. If found

In the early morning of June 20th, Beijing time, CVPR2024, the top international computer vision conference held in Seattle, officially announced the best paper and other awards. This year, a total of 10 papers won awards, including 2 best papers and 2 best student papers. In addition, there were 2 best paper nominations and 4 best student paper nominations. The top conference in the field of computer vision (CV) is CVPR, which attracts a large number of research institutions and universities every year. According to statistics, a total of 11,532 papers were submitted this year, and 2,719 were accepted, with an acceptance rate of 23.6%. According to Georgia Institute of Technology’s statistical analysis of CVPR2024 data, from the perspective of research topics, the largest number of papers is image and video synthesis and generation (Imageandvideosyn

We know that LLM is trained on large-scale computer clusters using massive data. This site has introduced many methods and technologies used to assist and improve the LLM training process. Today, what we want to share is an article that goes deep into the underlying technology and introduces how to turn a bunch of "bare metals" without even an operating system into a computer cluster for training LLM. This article comes from Imbue, an AI startup that strives to achieve general intelligence by understanding how machines think. Of course, turning a bunch of "bare metal" without an operating system into a computer cluster for training LLM is not an easy process, full of exploration and trial and error, but Imbue finally successfully trained an LLM with 70 billion parameters. and in the process accumulate

Editor of the Machine Power Report: Yang Wen The wave of artificial intelligence represented by large models and AIGC has been quietly changing the way we live and work, but most people still don’t know how to use it. Therefore, we have launched the "AI in Use" column to introduce in detail how to use AI through intuitive, interesting and concise artificial intelligence use cases and stimulate everyone's thinking. We also welcome readers to submit innovative, hands-on use cases. Video link: https://mp.weixin.qq.com/s/2hX_i7li3RqdE4u016yGhQ Recently, the life vlog of a girl living alone became popular on Xiaohongshu. An illustration-style animation, coupled with a few healing words, can be easily picked up in just a few days.

Title: A must-read for technical beginners: Difficulty analysis of C language and Python, requiring specific code examples In today's digital age, programming technology has become an increasingly important ability. Whether you want to work in fields such as software development, data analysis, artificial intelligence, or just learn programming out of interest, choosing a suitable programming language is the first step. Among many programming languages, C language and Python are two widely used programming languages, each with its own characteristics. This article will analyze the difficulty levels of C language and Python
