nest

Elastic Search 5.x Nest Multiple Queries C#

风流意气都作罢 提交于 2019-12-06 06:14:23
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 QueryContainer(); termQueryContainer.Term = new

elasticsearch nest support of filters in functionscore function

时光总嘲笑我的痴心妄想 提交于 2019-12-06 05:05:50
问题 I am currently trying to implement a "function_score" query in NEST, with functions that are only applied when a filter matches. It doesn't look like FunctionScoreFunctionsDescriptor supports adding a filter yet. Is this functionality going to be added any time soon? Here's a super basic example of what I'd like to be able to implement: Runs an ES query, with basic scores Goes through a list of functions, and adds to it the first score where the filter matches "function_score": { "query": {..

How to convert ISearchResponse <dynamic> to C# Class Object?

谁都会走 提交于 2019-12-06 05:03:50
问题 How to convert ISearchResponse to C# Class Object. I am trying to convert to Class Object where my Class name will be dynamic. ISearchResponse<dynamic> bResponseNewLoop = objElastic.Search<dynamic>(s => s .Index("index1") .Type("DOCTYPE") .From(0) .Size(10) .Source(sr => sr.Include(RequiredFields))); From above Response , i want to convert the response object to class object and The class name i am retriving from xml file. 回答1: In newer NEST versions we introduced IDocument which allows you

DeleteByQuery using NEST and ElasticSearch

夙愿已清 提交于 2019-12-06 04:23:24
问题 I'm having a little difficulty getting NEST's DeleteByQuery method to work. Very simply the query never finds anything to delete, and I can't figure out why. I'm using the same query to return records (using Search) and everything works as expected. private void Delete(MyClass someObject) { var response = elasticClient.DeleteByQuery<MyClass>(q => q .Match(m => m.OnField(f => f.Guid).Equals(someObject.Guid)) ); } I've only just started using NEST, so I'm sure this is a pretty simple problem

Elasticsearch.net client can't do basic search

前提是你 提交于 2019-12-06 02:41:53
问题 I have a basic Elasticsearch query that looks like this POST /fruit/_search {"query":{"term":{"Name":"banana"}}} I get result back, no problems when I run in sense. So I try to do this in elasticsearch.net var requestBody = new { query = new { term = new { Name = "banana" } } }; var result = client.Search<string>("fruit", requestBody); And I get no results back. If I just have a search body with new {} then I get hits, but not filtered. What am I doing wrong? 回答1: If you use the low level

elasticsearch NEST client, filed with attribute “not_analyzed” still be analyzed when search keywords contains hyphen

梦想与她 提交于 2019-12-05 21:16:51
I have a class named "IndexModel": public class IndexModel { [ElasticProperty(Index= FieldIndexOption.NotAnalyzed, Store = true)] public string ModelNumber{ get; set; } } following is how i setup the elastic client: var uri = new Uri("http://localhost:9200"); var config = new ConnectionSettings(uri); var client = new ElasticClient(config); client.Map<IndexModel>(m => m.MapFromAttributes()); I can see the mapped result from response: Request { "indexmodel": { "properties": { "modelNumber": { "type": "string", "store": true, "index": "not_analyzed" }, } } } and i have one index record for this

ElasticSearch and Nest filtering does not work

有些话、适合烂在心里 提交于 2019-12-05 20:54:42
I run a query that returns 10 results. There is a property in my document called Type. The value of this property for some records is an empty string and for some other records is either "AudioAlbum" or "AudioRington". I want to do two things: 1- Exclude the documents that their Type property does not have a value from the search result. 2- Get AudioAlbums only (as a different search). My search code for getting AudioAlbums is this: var docs = client.Search<content>( b => b.Type("content") .Query(q => q.Fuzzy(fz => fz .OnField("title").Value(keyWord) .OnField("artists.name"))) .Filter(x => x

How to search inside multiple indices using Nest ElasticSearch?

放肆的年华 提交于 2019-12-05 20:06:46
I have two indices with the following mapping(I will shortcut their mappings): 1) AccountType mapping: elasticClient.CreateIndex("account", i => i .Settings(s => s .NumberOfShards(2) .NumberOfReplicas(0) ) .Mappings(m => m .Map<AccountType>(map => map .AutoMap() .Properties(p => p .Text(c => c .Name(n => n.Name) .Analyzer("standard") ) .Text(c => c .Name(n => n.Description) .Analyzer("standard") ) ) ) ) ); 2) ProductType mapping: elasticClient.CreateIndex("proudct", i => i .Settings(s => s .NumberOfShards(2) .NumberOfReplicas(0) ) .Mappings(m => m .Map<ProductType>(map => map .AutoMap()

Favor exact matches over ngram matches in ElasticSearch when mapping

£可爱£侵袭症+ 提交于 2019-12-05 19:16:23
问题 I have partial matching of words working with ngrams. How can I modify the mapping to always favor exact matches over ngram tokens? I do not want to modify the query. One search box will search multiple types, each with their own fields. For example, lets say I'm searching job titles, one person has a title of "field engineer", the other a title of "engine technician". If a user searches for "engine", I'd want ES to return the latter as more relevant. I'm using this mapping almost verbatim:

Creating a custom analyzer in ElasticSearch Nest client

你。 提交于 2019-12-05 17:00:43
Im very very new to elasticsearch using the nest client, I am creating an index with a custom analyzer, however when testing using analyze it does not seem to use the custom analyzer. Mainly no edgengram tokens appear. Is there anything I am missing that would make my custom analyser the default for the index? When I check my mappings using elastichq they show my custom analyzer. ConnectionSettings settings = new ConnectionSettings(new Uri("http://localhost:9200"), defaultIndex: "forum-app"); IndexSettings indsettings = new IndexSettings(); var an = new CustomAnalyzer(); an.CharFilter = new