nest

Specifying and using a NGramTokenizer with the C# NEST client for Elastic Search

筅森魡賤 提交于 2019-12-03 14:23:21
Updated to show a working sample I am trying to do a partial search on a collection of usernames in ElasticSearch. Searching around has pointed me in the nGram Tokenizer direction but I am stumped at proper implementation and fail to get any results. This is the the relevant code stripped from the project I'm working on. I have tried different combinations and search types to no avail. setup.cs var client = new ElasticClient(settings.ConnectionSettings); // (Try and) Setup the nGram tokenizer. var indexSettings = new IndexSettings(); var custonAnalyzer = new CustomAnalyzer(); customAnalyzer

Searching ElasticSearch using NEST C# Client

青春壹個敷衍的年華 提交于 2019-12-03 13:34:41
问题 I started looking around for a search engine and after some reading I decided going with ElasticSearch (which is quite amazing :)), my project is in C# so I looked around for a client and started using NEST, everything is quite straightforward but I am a bit confused on the searching part. I want to search all fields on a specific type what I came up with is the following code: elasticClient.Search<NewType>(s => s.Query(q => q.QueryString(d => d.Query(queryString)))); I saw that much of the

Proper way to do multi field with NEST

浪尽此生 提交于 2019-12-03 12:57:42
I want to implement full text search and tokenized search with NEST, so I want to get multifield like that : "tweet": { "properties": { "message": { "type": "string", "store": true, "fields": { "raw": { "type": "string", "index": "not_analyzed" } } } } } Currently, my mapping with NEST is [ElasticType(Name = "tweet")] internal class Tweet { [ElasticProperty(Name = "message")] public string Message { get; set; } } I searched in the documentation on NEST and ElasticSearch.net but nothing came by. Is there any option to get a raw field inside a field automatically or should I define a nested

Elastic Search 5.x Nest Multiple Queries C#

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using C# with those nuget packeges; <package id="Elasticsearch.Net" version="5.2.0" targetFramework="net462" /> <package id="NEST" version="5.2.0" targetFramework="net462" /> <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net462" /> What I want to do here, I want to get "white" items in price range 2000 - 3000. It's a simple request for a search api, am I right ? So I wrote a code for this. Here it is; private static void Search(IElasticContext elasticContext, string indexName) { IQueryContainer termQueryContainer = new

Multi Terms search NEST C#

匿名 (未验证) 提交于 2019-12-03 08:42:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to do a search matching multiple values ( an array of values ) like this : var result1 = _client.Search<type1>(s => s .Fields(f => f.trip_id) .Query(q => q .Terms(t => t.arg1, value1)).Take(_allData)) .Documents.Select(d => d.arg2).ToArray(); var result2 = _client.Search<type2>(s => s .Query(q => q .Terms(t => t.arg3, result1)) .Take(_allData) ).Documents.Select(s => s.ar3).ToList(); How can I do ? I was thinking about facets but I don't see how I can do it. The only way for now that works is with a foreach iterator which is not

Create index with multi field mapping syntax with NEST 2.x

风格不统一 提交于 2019-12-03 08:41:25
I just can't seem to get the syntax correct for multi field mapping in NEST 2.0--if that's the correct terminology. Every example I've found for mapping seems to be <= the 1.x version of NEST. I'm new to Elasticsearch and NEST, and I've been reading their documentation, but the NEST documentation hasn't been completely updated for 2.x. Basically, I don't need to index or store the entire type. Some fields I need for indexing only, some fields I'll need to index and retrieve, and some I don't need for indexing, just for retrieval. MyType { // Index this & allow for retrieval. int Id { get; set;

NEST Conditional filter query with multiple terms

非 Y 不嫁゛ 提交于 2019-12-03 06:53:25
问题 I would like to do a ElasticSearch query like this: { "query" : { "bool" : { "filter" : [ { "terms" : { "name" : ["name1", "name2"] } }, { "terms" : { "color" : ["orange", "red"] } } ] } } } I've tried to implement it in NEST like this: _elasticClient .SearchAsync<MyDocument>(s => s.Index("myindex") .Query(q => q .Bool(bq => bq .Filter(fq => { QueryContainer query = null; if (nameList.Any()) { query &= fq.Terms(t => t.Field(f => f.Name).Terms(nameList)); } if (colorList.Any()) { query &= fq

Scroll example in ElasticSearch NEST API

不羁岁月 提交于 2019-12-03 06:35:32
I am using .From() and .Size() methods to retrieve all documents from Elastic Search results. Below is sample example - ISearchResponse<dynamic> bResponse = ObjElasticClient.Search<dynamic>(s => s.From(0).Size(25000).Index("accounts").AllTypes().Query(Query)); Recently i came across scroll feature of Elastic Search. This looks better approach than From() and Size() methods specifically to fetch large data. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html I looking for example on Scroll feature in NEST API. Can someone please provide NEST example?

Facet on nested field with Elasticsearch C# Mpdreamz/NEST client

孤街浪徒 提交于 2019-12-03 06:25:45
问题 How to list a facet based on a property of a nested field using Mpdreamz/NEST Elasticsearch client? I checked the Nest documentation, but it's not clear how to do it. This is the code that I tried: using System; using System.Collections.Generic; using System.Linq; using Nest; namespace Demo { class Program { public class Movie { public int Id { get; set; } public string Title { get; set; } public string Description { get; set; } [ElasticProperty(Index = FieldIndexOption.analyzed, Type =

Searching ElasticSearch using NEST C# Client

≯℡__Kan透↙ 提交于 2019-12-03 03:28:31
I started looking around for a search engine and after some reading I decided going with ElasticSearch (which is quite amazing :)), my project is in C# so I looked around for a client and started using NEST , everything is quite straightforward but I am a bit confused on the searching part. I want to search all fields on a specific type what I came up with is the following code: elasticClient.Search<NewType>(s => s.Query(q => q.QueryString(d => d.Query(queryString)))); I saw that much of the string query search is deprecated and wanted to make sure the above is the correct way of doing this