nest

Create custom token filter with NEST

喜夏-厌秋 提交于 2019-11-29 06:45:31
How can I configure Index using NEST with such JSON: "settings":{ "analysis":{ "filter":{ "name_ngrams":{ "side":"front", "max_gram":50, "min_gram":2, "type":"edgeNGram" } }, "analyzer":{ "partial_name":{ "filter":[ "standard", "lowercase", "asciifolding", "name_ngrams" ], "type":"custom", "tokenizer":"standard" } } } I could create my custom analyzer using CustomAnalyzer class, but I could'n find how to create custom filter and register it within my analyzer. Thanks in advance! After some searching I've found a solution: var partialName = new CustomAnalyzer { Filter = new List<string> {

Eloquent JavaScript #15# Asynchronous Programming(渣翻)

这一生的挚爱 提交于 2019-11-29 04:44:02
// 删了浪费 1、异步VS.同步 知乎 上看到的一个解释。 打个比方。你去书店借书,问书店老板有没有《代码大全》。 如果是同步的处理方式,老板会说:“你在这儿站着别动,我去找找看”。于是你在柜台等啊等啊,直到老板重新出现并告诉你结果。而异步的处理方式则是,老板直接告诉你,让我找一下啊,等会儿打电话通知你,然后你就开开心心地(?)回家了... 2、乌鸦科技 许多人都知道乌鸦是一种特别聪明的鸟。它们能够使用工具,提前做好计划,记住事情,甚至互相交流。 但大多数人所不知道的是,它们还隐藏了许多我们所不知道的能力。我听一位很有信誉的鸦科专家说,乌鸦的科技距离人类并不是非常遥远,并且它们正在迎头赶上。 举个例子,许多乌鸦文明都具有构建计算设备的能力。这些设备不同于人类的电子计算设备,而是通过微小昆虫们的行动来运作,这些昆虫是与白蚁密切相关的物种,它们和乌鸦形成了共生关系。乌鸦为它们提供食物,作为回报,昆虫构建和操控它们复杂的菌落,在他们内部生物的帮助下进行计算。 这些菌落通常位于大且存在时间长的乌鸦巢中。乌鸦和昆虫共同构建了一个球状粘土结构的网络,隐藏在构成乌鸦巢的树枝之间,昆虫正是在这里生活和工作。 这些机器采用光信号和其它设备通信。乌鸦将反光材料嵌入特殊的通信杆中,昆虫用这些材料将光线反射到另一个巢穴,将数据编码为一系列快速的闪光。 我们的朋友,鸦科专家已经绘制了Rh

How to disable camel casing Elasticsearch field names in NEST?

本小妞迷上赌 提交于 2019-11-29 03:43:36
By default, NEST will camel case object and property names when sending an object to Elasticsearch for indexing. How can camel casing field names be disabled in NEST for Elasticsearch documents? I've done a fair amount of research and there's a mailing list thread on the subject, but it seems outdated as some of the methods have been renamed or no longer exist. IConnectionPool connectionPool = new SniffingConnectionPool(m_ElasticsearchNodeUris); ConnectionSettings settings = new ConnectionSettings(connectionPool); settings.SetDefaultTypeNameInferrer(p => p.Name); //This disables camel casing

Nest 2.0 enable trace

大城市里の小女人 提交于 2019-11-29 03:33:23
问题 I am on updating to the latest Nest version. Since I am getting not the expected results I am searching for replacement of the EnableTrace() method which was a method of ConnectionSettings on previous versions. 回答1: EnableTrace() will be back, but it's not available yet(have a look). For now you can use this code to print out information about request and response: var settings = new ConnectionSettings(connectionPool) .DefaultIndex(indexName) .DisableDirectStreaming() .OnRequestCompleted

Elastic Search using NEST Field Boosting

↘锁芯ラ 提交于 2019-11-29 02:59:13
问题 I am using Elastic Search in C# using the NEST strongly typed client. I have an index containing Entries: [ElasticType(Name = "Entry", IdProperty = "Id")] public class Entry { public string Id { get; set; } public string Title { get; set; } public string Description { get; set; } public string Award { get; set; } public int Year { get; set; } } Where Year is the year of the entry, eg 2012, and Award is the type of Award the Entry won, which can be null. I then want to search these Entries

How do I update an existing document inside ElasticSearch index using NEST?

允我心安 提交于 2019-11-28 22:33:36
问题 I am trying to update an existing indexed document. I have indexed tags, title and owners field. Now when the user changes the title, I need to find and update the document inside the index. Should I update and replace the entire document or just the title field? public void UpdateDoc(ElasticsearchDocument doc) { Uri localhost = new Uri("http://localhost:9200"); var setting = new ConnectionSettings(localhost); setting.SetDefaultIndex("movies"); var client = new ElasticClient(setting);

Index a dynamic object using NEST

让人想犯罪 __ 提交于 2019-11-28 20:50:26
I am building an API application that essentially allows a user to build a document, which can be structured however they want, that will be stored in Elasticsearch. Essentially, I'm providing a simple interface for users to access our Elasticsearch instance. I'm trying to keep the implementation as simple as possible. Here's what I'm dealing with so far. The object for the expected body: public class DocumentModel { public string Index { get; set; } public string Type { get; set; } public string Id { get; set; } [ElasticProperty(Type = FieldType.Nested)] public dynamic Document { get; set; }

Filter items which array contains any of given values

耗尽温柔 提交于 2019-11-28 16:38:40
I have a set of documents like { tags:['a','b','c'] // ... a bunch properties } As stated in the title: Is there a way to filter all documents containing any of given tags using Nest ? For instance, the record above would match ['c','d'] Or should I build multiple "OR"s manually ? Edit: The bitset stuff below is maybe an interesting read, but the answer itself is a bit dated. Some of this functionality is changing around in 2.x. Also Slawek points out in another answer that the terms query is an easy way to DRY up the search in this case. Refactored at the end for current best practices. —nz

Using InMemoryConnection to test ElasticSearch

百般思念 提交于 2019-11-28 12:43:21
I'm trying to add testing around our use of ElasticSearch (in C# using Nest 1.4.2) and want to use InMemoryConnection but I'm missing something (I assume) and having no success. I've created this simple Nunit test case as a boiled down example of my issue using System; using Elasticsearch.Net.Connection; using FluentAssertions; using Nest; using NUnit.Framework; namespace NestTest { public class InMemoryConnections { public class TestThing { public string Stuff { get; } public TestThing(string stuff) { Stuff = stuff; } } [Test] public void CanBeQueried() { var connectionSettings = new

Elasticsearch bulk insert with NEST returns es_rejected_execution_exception

本秂侑毒 提交于 2019-11-28 11:03:12
问题 I am trying to do bulk insert using .Net API in Elasticsearch and this is the error that I am getting while performing the operation; Error {Type: es_rejected_execution_exception Reason: "rejected execution of org.elasticsearch.transport.TransportService$6@604b47a4 on EsThreadPoolExecutor[bulk, queue capacity = 50, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@51f4f734[Running, pool size = 4, active threads = 4, queued tasks = 50, completed tasks = 164]]" CausedBy: ""} Nest