FAQ Database Discussion Community


How to use arrays in lambda expressions?

c#,elasticsearch,nest
I am writing a program with NEST library of ElasticSearch. I want to write a lambda expression for a function with this argument: HighlighDescriptor<parentdocument> HighlighDescriptor.onFields (param Action<HighlightFieldDescriptor<ParentDocument>>[] fieldHighlighters) I don't know what is the array in the function argument?...

Elasticsearch Nest Query Filter

sql,sql-server,elasticsearch,nest
I want to get records through filter. Sql Query: SELECT * FROM testdb Where contactId = "e84aca88-7b82-43d9-8788-4cc25af0c43a" Json Query : { "from": 0, "size": 200, "query": { "filtered": { "filter": { "bool": { "must": { "query": { "match": { "contactId": { "query": "e84aca88-7b82-43d9-8788-4cc25af0c43a", "type": "phrase" } } } } }...

Get raw query from NEST client

elasticsearch,nest
Is it possible to get the raw search query from the NEST client? var result = client.Search<SomeType>(s => s .AllIndices() .Type("SomeIndex") .Query(query => query .Bool(boolQuery => BooleanQuery(searchRequest, mustMatchQueries))) ); I'd really like to debug why I am getting certain results....

How do you debug your Nest queries?

c#,elasticsearch,nest
I'm new to Nest, and I very likely am not creating my query like I think I am. My question is more along the lines of teach a man to fish rather than give me a fish. However, I'll use my current problem as an example. I have several documents...

Elastic Search. Net With Nest: Term Filter For Elastic Property

filter,elasticsearch,nest,elastic
I am attempting to perform a query with filters. I can get it to filter on some properties but not the one I need. Here is my model: public class IndexItem { public DateTime CreatedDate { get; set; } [ElasticProperty(Index = FieldIndexOption.Analyzed)] public String Name { get; set; } [ElasticProperty(Index...

ElasticSearch (Nest) Terms sub aggregation of Terms - Not working as intended

elasticsearch,nest
Taking the following mapping in account : { "person": { "properties": { "id": { "type": "string" }, "name": { "type": "string" }, ... "trainings": { "properties": { "attendanceDate": { "type": "date", "format": "dateOptionalTime" }, "providerId": { "type": "string", "index": "not_analyzed" }, "trainingId": { "type": "string", "index": "not_analyzed" } ... }...

Ignoring TypeConverter attribute in Elasticsearch Nest

c#,elasticsearch,json.net,nest
I have reference to several classes defined in an external library that contain a TypeConverter attribute. Due to this attribute, Json.Net, and consequently Nest, is incorrectly serializing these objects. The correct way to serialize these objects is to ignore the TypeConverter attribute and make use of the object properties. In...

Fields search does not return field values

elasticsearch,nest
I am trying to select only specific fields in my search over index with >100 fields using NEST client. The search returns 10K results as expected, but when looping over hits field values dictionary is null (I see it in debugger). Below is the code: var elastic = new ElasticClient(new...

How can I use NEST QueryString and escape the special characters?

c#,elasticsearch,nest
I am using NEST to communicate with Elasticsearch in my applications. In this case, the user enters in their search term F5503904902 which returns the correct result. However, if they search for the query F5503904902-90190 or F5503904902-90190_55F the results do not come back. I assumed this was because of the...

Nest - ElasticSearch.Net - How do I split the FacetFilter hit count returned by a search property

c#,elasticsearch,nest
I have a NEST Query; var desciptor = new SearchDescriptor<SomePoco>() .TrackScores() .From(request.Page == 1 ? 0 : (request.Page - 1) * request.PageSize) .Size(request.PageSize) .MatchAll() .FacetFilter("some_name", a => new FilterContainer(new AndFilter { Filters = CreatePocoSearchFilter(request) })) .SortDescending("_score"); var results = _client.Search<SomePoco>(x => descriptor); The FacetFilter is returning the total number of...

Nest/ElasticSearch Sorting by _uid

c#,sorting,elasticsearch,nest
I'm trying to pull back records based on a query and sort them using the _uid field. In my case the _uid is the Type followed by # followed by the id that I set. My index is full of files of code and an example of the _uid would...

How to search multiple conditions in ElasticSearch

c#,elasticsearch,nest
I'm using Nest to connect to ElasticSearch and perform some queries. Until now, I've been able to get the results I'm asking for given a single wildcard query as below: var searchResults = _client.Search<MyIndexable>( body => body .Index("someIndex") .Query( query => query.QueryString( qs => qs. OnFields(f => f.Title, f =>...

Documents with a geo_shape field cannot be deserialized?

c#,elasticsearch,json.net,nest,elasticsearch-geo-shape
My index contains a field that is of type Nest.GeoShape. ---------- Problem #1 -- Kibana shows that field as "indexed = false" even though it has been defined like this (with .MapFromAttributes() during index creation)... [ElasticProperty(Index = FieldIndexOption.NotAnalyzed, Store = true, IncludeInAll = false)] public Nest.GeoShape ElasticShape { get; set;...

Active Directory AuthorizationException in elastic search

elasticsearch,nest,elasticsearch-plugin,elastic,elasticsearch-shield
I am trying to use AD authentication. I am able to login successfully but i am not authorized to perform any query in marvel. Everytime i execute query in marvel, i get the following error.Below are the details { "error": "AuthorizationException[action [indices:data/read/search] is unauthorized for user [shivang.Mittal]]", "status": 403 }...

date filter using elasticsearch, using nest c#

c#,datetime,elasticsearch,nest
I am having mapping for a date field like shown below. .Date(s => s.Name("createdOn").Format("yyyy-MM-dd'T'HH:mm:ss.SSS||yyyy-MM-dd'T'HH:mm:ss||MM/dd/yyyy||yyyy/MM/dd")) I want to get documents created after a certain date. I am passing date as string in the format MM/dd/yyyy to the filter range like shown below.. DateTime date; DateTime.TryParse(filter.SearchText, out date); string dateString = date.ToString("MM/dd/yyyy");...

Re-index object with new fields

elasticsearch,nest
It seems like as long as the id field is maintained, its super easy to re-index a document by simply calling Index(), but is there a way to given an object was updated and new fields were added, to have it include these new fields in the index? I'm not...

ElasticSearch - how to get the auto generated id from an insert query

c#,mysql,database,elasticsearch,nest
On my ElasticSearch database I need to get the autogenerated id from my insert query (I'm using .NET C#). How to do it? I tried debugging the readRecords response but I didn't find such id. Basically I need the equivalent of the MySQL LAST_INSERT_ID() command. var readRecords = elasticClient.Search<HistoryRecord>(s =>...

Elasticsearch Completion Suggester field contains comma separated values

search,elasticsearch,lucene.net,nest,elastic
I have a field that contains comma separated values which I want to perform suggestion on. { "description" : "Breakfast,Sandwich,Maker" } Is it possible to get only applicable token while performing suggest as you type?? For ex: When I say break, how can I get only Breakfast and not get...

Nest: Indexing a PDF, recieving Status Code 400, “No Content Provided”

c#,elasticsearch,nest
I'm trying to index and search a PDF based off what I learned here: ElasticSearch & attachment type (NEST C#) But am getting a "Status Code 400, No Content Provided" error. The pdf is about 7KB in size, about as small as I could make one, just has some text...

Elasticsearch query using NEST & QueryRaw

elasticsearch,nest,elasticsearch-net
I have the following Elastic Search query: { "query": { "filtered": { "query": { "multi_match": { "query": "main", "type": "cross_fields", "fields": [ "field1^5", "test", "field2", "abc" ], "operator": "and" } } } }, "sort": [], "from": 0, "size": 20 } I am trying to run this query using NEST client...

Elastic Search-Search string having spaces and special characters in it using C#

c#-4.0,elasticsearch,couchbase,nest
I am looking for ElasticSearch nest query which will provide exact match on string having spaces in it using C#. for example - I want to search for a word like 'XYZ Company Solutions'. I tried querystring query but it gives me all the records irrespective of search result. Also...

Updating field of million of document from a worker

elasticsearch,nest,ironworker
Currently I have to update a field in over 1 million documents indexed in elasticsearch. This is a complex task due to this field contains metadata generated from XML files, evaluating xpath expressions. We have to loop over all the documents in the index and update this field. So, in...

How to append two SearchDescriptors in NEST

c#,elasticsearch,nest
I am taking input from a client to build up an elasticsearch query using NEST. I start out with the basics, like so: var search = esClient.Search<MyData>(s => s .From(pageNum * pageSize) .Take(pageSize) .QueryRaw(@"{""match_all"": {} }") I then parse out the request and see if an optional sorting parameter was...

LINQ in NEST framework for ElasticSearch

.net,linq,elasticsearch,nest
Can I use LINQ in NEST/ElasticSearch? If answer is YES where I can find documentation of it?

NEST - Using GET instead of POST/PUT for searching

c#,elasticsearch,nest
Is there a way to tell NEST to use GET instead of POST when performing searches? Similar to how the ElasticSearch documentation shows CURL using GET I'd like to use GET when using NEST instead of using POST as it currently does.

Using plain double Latitude / Longitude Properties for Nest / ElasticSearch.Net

elasticsearch,nest
I am a tad confused when it comes to indexing my domain models that include plain Latitude / Longitude (both double properties) with Nest / ElasticSearch.Net: Is there a way to map those two POCO / double properties over & tell ElasticSearch.Net that these two are actually what they are,...

Nest can't cope with a big database model with EF6/MVC5

c#,entity-framework,elasticsearch,asp.net-mvc-5,nest
I've been given a database against which basic CRUD operations should be possible. This was quickly accomplished by using .NET 4.5/MVC5 and EF6. This means Database First approach. New requirement: (Elastic)Search. When creating an index for a custom class (not linked to others in the model), everything is fine. When...

Insert data to ElasticSearch using NEST API

elasticsearch,nest
I am trying to insert\bulk insert data to Elastic using NEST API. Can someone provide me the example using NEST? Thanks, Sameer...

Configuring ElasticClient connection pooling

elasticsearch,nest
I am currently updating our elasticsearch code to use the built-in Connection Pooling offered by Nest's IElasticClient. So before we were using var settings = new ConnectionSettings(new Uri(connString)); var esClient = new ElasticClient(settings); and now I want to be able to pass in a configured connection pool (as mentioned in...

How to write a percolator query to nest program

elasticsearch,nest
I have a percolator query in elastic search as below. put /skill-index PUT /skill-index/skill-type/_mapping { "properties" : { "message" : { "type": "string" } } } PUT /skill-index/.percolator/101 { "query" : { "match" : { "message" : "crossstitch" } } } PUT /skill-index/.percolator/102 { "query" : { "match" : {...

In elastic search is a collection queryable while its being added to the index

elasticsearch,nest,elastic
I'm using Nest to insert a list of 60k+ objects into elastic search, specifically calling client.IndexMany(list, indexName). As the list is inserted, is it query-able? or is it only query-able after the complete list is indexed? If its the former, is there a way to force it to only be...

Elasticsearch/Nest - using MatchPhrase with OnFieldsWithBoost

c#,elasticsearch,nest
In my code today I am doing a search like this: .Query(q => q.QueryString(qs => qs.Query(searchQuery).OnFieldsWithBoost(f => f.Add(b => b.MetaTitle, 5).Add(b => b.RawText, 1)))) My problem is this gives me a very wide search if I search on a phrase like. "The sun is shining". I have tried using MatchPhrase...

How to remove default mapping of index without deleting its data of elasticsearch

c#-4.0,elasticsearch,couchbase,nest
I have some documents in Couch-base in which some field values are having space in it ("Ex. "New York"). I am not able to search it as exact match using term query. I found that for searching the field values which are have space require some mapping like - index...

Blocking an index for readonly operations, makes elasticsearch left in an inconsistent state

elasticsearch,nest
I want to block an index from write operations if I have to make a reindex process of this index. This both posts(elasticsearch migrations with c and nest & NEST Elasticsearch Reindex examples) were very helpful, but as suggested by this third one, you can lost updates and deletes in...

Elasticsearch NEST library, wired behavior

.net,elasticsearch,nest
Using NEST .NET library I worte following query. var result = client.Search<StudenntBrief>(s => s.Type("Students").Query(q => q.Term("Name","Robert"))); It worked fine and got 7 results. Instead of using maigic string to represent field i tried to use expression as follows. var result = client.Search<StudenntBrief>(s => s.Type("Students").Query(q => q.Term(t => t.Name,"Robert"))); I found...

Bulk insert documents to ElasticSearch without updating when document exists

elasticsearch,nest,elastic
Is it possible to bulk insert data to ES without updating document content if exists by Id. Only not existing documents should be inserted, without any updates.

MultiMatch query with Nest and Field Suffix

c#,elasticsearch,nest
Using Elasticsearch I have a field with a suffix - string field with a .english suffix with an english analyser on it as shown in the following mapping ... "valueString": { "type": "string", "fields": { "english": { "type": "string", "analyzer": "english" } } } ... The following query snippet won't...

Elasticsearch and C# - query to find exact matches over strings

c#,.net,database,elasticsearch,nest
I need a way to search documents using a plain exact match over two or multiple fields which are of type "string" and "integer". I'd like to avoid standard query as I don't care about scoring or best match, just a yes/no outcome if both the fields match or not....

Elastic Search - Creating Query with NEST

elasticsearch,nest
Given the query: GET places/_search { "query": { "match_all": {} }, "size": 0, "aggs": { "filtered_cells": { "filter": { "geo_bounding_box": { "loc": { "top_left": { "lat": 53.480950, "lon": -2.2374300 }, "bottom_right": { "lat": 51.5085300, "lon": -0.1257400 } } } }, "aggs": { "cells": { "geohash_grid": { "field": "loc", "precision": "precision"...

Elasticsearch getting distance with different sort order

c#,elasticsearch,nest
Background: We have requirement for following: Data matching keyword should be returned. Data has longitude and latitude fields, result should be near specified lat long. Returned result should contain distance field, which specified distance between given lat long and lat long contained in data. Data should be sorted accouding to...

ElasticSearch / NEST / No results with “Term” but with “Match”

elasticsearch,nest
Why does the first statement give me some results but the second not? I tried a lot of combinations, but I don't get any idea what the problem might be. Of course the "Term"-Approach would be my preferred one. var matchPhrase = _client.Search<JournalItem>(s => s .Index("journal") .Query(q => q.Match(m =>...

Query returns both documents instead of just one

c#,.net,elasticsearch,nest
var res = esclient.Search<MyClass>(q => q .Query(fq => fq .Filtered(fqq => fqq .Query(qq => qq.MatchAll()) .Filter(ff => ff .Bool(b => b .Must(m1 => m1.Term("macaddress", "mac")) .Must(m2 => m2.Term("another_field", 123)) ) ) ) ) ); As far as I can understand the bool and must together are the equivalent of the...

Nest elastic search.net not returning any results via any query

asp.net,asp.net-mvc,nest,elasticsearch-net
I've created an index in sense which I'm happy with and am trying to implement a typed query in the NEST client as follows: var node = new Uri("http://elasticsearch-blablablamrfreeman"); var settings = new ConnectionSettings(node) .SetTimeout(300000) .SetDefaultIndex("films") .MapDefaultTypeIndices(d => d .Add(typeof(film), "films")) .SetDefaultPropertyNameInferrer(p=>p); Inject it (amongst the searcher and indexer) with...

ElasticSearch - NEST Query Condition Limit

elasticsearch,nest
After searching on Google, i found the Elasticsearch max query condition limit is 1024? Is it configurable? If yes can you anyone please provide the steps. Thanks, Sameer...

How to use ElasticSearch MinHash plugin in NEST

nest,elastic
I want to use MinHash elastic search plugin in NEST Elasticsearch.net. How can I use minhash plugin in nest?

Operator '??' cannot be applied to operands of type IQueryContainer and lambda expression

c#,elasticsearch,nest
I am trying to create a method to process a certain query. I follow an example posted on the Nest repository (line 60), but still the MatchAll is not recognized by the compiler and if I try to build the solution, the error that shows is: Operator '??' cannot be...

How can I see the NEST.SearchRequest.Type property's effect on my ElasticSearch Query

elasticsearch,nest
I'm attempting to query a dynamic list of types in my ElasticSearch index using a NEST SearchRequest object. public object Search(object runTimeData) { var request = new SearchRequest() { From = 0, Size = 10 }; request = SetRouting(request, runTimeData); request = SetIndices(request, runTimeData); request = SetTypes(request, runTimeData); request =...

Bulk insert to ElasticSearch with NEST

c#,elasticsearch,nest,elasticsearch-net
I try to add 100k products to elasticsearch, but when i try i get: {"Validation Failed: 1: no requests added;"} My code: var Node = new Uri("......"); var ConnectionPool = new SniffingConnectionPool(new[] { Node }); var Config = new ConnectionConfiguration(ConnectionPool) .SniffOnConnectionFault(false) .SniffOnStartup(false) .SniffLifeSpan(TimeSpan.FromMinutes(10)); var Client = new ElasticsearchClient(Config); var AllProducts...

Elasticsearch - Nest - specific search

c#,elasticsearch,nest
In relation to the question: Elasticsearch/Nest - using MatchPhrase with OnFieldsWithBoost I have an index which looks something like this: { "_index": "myIndex", "_type": "Page", "_id": "119", "_score": 0.104187615, "_source": { "dataBaseId": 119, "category": "InfoPage", "type": "Page", "metaTitle": "myMeta", "metaDescription": "Description", "rawText": "my search text" } } My code looks...

Where to get ElasticSearch document version using NEST

c#,elasticsearch,nest
It should be in the Hits[i].Version but that is always null when I look at the ISearchResponse. I've also set the .EnableMetrics on the ConnectionSettings object but no luck as the version is always null. I have double checked ElasticSearch and the document versions are incrementing fine in there. So...

NEST elasticsearch.NET search query not returning results (part 2)

elasticsearch,nest,elasticsearch-plugin
I'm using the object initializer syntax with NEST to form a search query. When I include the second pdfQuery with the logical OR operator, I get no results. If I exclude it, I get results. QueryContainer titleQuery = new MatchQuery { Field = Property.Path<ElasticBook>(p => p.Title), Query = query, Boost...

Possible to do multifield range query?

elasticsearch,nest,elasticsearch-net
I would like to execute a range query against multiple fields, or a field with a suffix, like markups.*. There doesn't seem to be a way to do this in Nest or Elasticsearch. For example this query in ES returns results: { "query": { "range": { "markups.1": { "gte": "2015-01-01T00:00:00.000",...

NEST ElasticSearch.NET Escape Special Characters

c#,elasticsearch,nest
I have been experimenting with the use of the NEST client for Elastic Search, but seem to have hit a barrier when filtering on a term which contains special/reserved characters such as '/' Below is a JSON representation of my model.. "categories": { "count": 1, "default": "root/Hello/World/Category", } When submitting...

Nest: how are you supposed to deal with the highlights in c#

c#,elasticsearch,nest
I'm trying to search "everything" in an index for a search term, and display the context with the terms highlighted. I get an appropriate set of documents returned, but cannot figure out how I'm supposed to handle the highlighting in code. At this point i'm just trying to dump it...

Elasticsearch - Order search results ASC

c#,sorting,elasticsearch,nest
having a problem with my elasticsearch. Setup: Having a Company-Class with the data field "companyName". My search shall search and response all companys with the searched term. If I try to sort via .Sort(x=> x.OnField(x => x.CompanyName).Descending()) The data aren't sorted rightly - reference stackOverflow I tried the given solution,...

Elasticsearch.NET NEST Object Initializer syntax for a highlight request

c#,nest,object-initializers,elasticsearch-net
I've got: var result = _client.Search<ElasticFilm>(new SearchRequest("blaindex", "blatype") { From = 0, Size = 100, Query = titleQuery || pdfQuery, Source = new SourceFilter { Include = new [] { Property.Path<ElasticFilm>(p => p.Url), Property.Path<ElasticFilm>(p => p.Title), Property.Path<ElasticFilm>(p => p.Language), Property.Path<ElasticFilm>(p => p.Details), Property.Path<ElasticFilm>(p => p.Id) } }, Timeout = "20000"...

ElasticSearch NEST UpdateDescriptor scriptId does not work, gives System.MissingMethodException

elasticsearch,nest
The newly added "ScriptId" for the UpdateDescriptor does not seem to work. At runtime I get the following error: System.MissingMethodException was unhandled HResult=-2146233069 Message=Method not found: 'Nest.UpdateDescriptor`2 Nest.UpdateDescriptor`2.ScriptId(System.String)'. Source=SMSProcessManagers StackTrace: at TestApp.TestApplication.Program.Main(String[] args) in e:\src\Applications\TestApplication\Program.cs:line 49 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at...

Elasticsearch/Nest - using MultiMatch TextQueryType.Phrase and wildcard

c#,elasticsearch,nest
In relation to the question: Elasticsearch/Nest - using MatchPhrase with OnFieldsWithBoost I would like to know if it is possible to extend the solution from that question to make elasticsearch search for everything matching "The sun is shin" and get results like "The sun is shining". I was thinking something...

How can I delete a specific river using NEST?

c#,.net,elasticsearch,nest
If _client is an IElasticClient instance, I can delete the _river index by doing the following: _client.DeleteIndex(i => i.Index("_river")); However, I want to keep some of my rivers intact. How can I delete a specific river?...

Querying Elastic using NEST does not return any response

elasticsearch,nest
I am indexing the following Document class for indexing: public class DoctorDocument { public int Id { get; set; } public string Name { get; set; } public int Age { get; set; } public int Experience { get; set; } } I am using the following code for searching...

Order by sum aggregation throws error in elastic search

c#,elasticsearch,nest
I am trying to sort the aggregated result by applying another aggregation that does the summing and then applying order by descending to that sum. if I try like below, the aggregation result get sorted by doc count. "order": { "revrsenestedowners": "desc" } Below code explains the problem am facing....

How to avoid to extend the mapping on commiting an object

elasticsearch,nest
Let's assume folowing class which I want to index: private class User { public User() { Id = Guid.NewGuid(); Added = DateTime.Now; } public Guid Id { get; protected set; } public string LastName { get; set; } public DateTime Added { get; protected set; } // Unimportant for search...

in NEST, how do I dynamically build a query from a list of terms?

elasticsearch,nest
Say my user provides a list of search terms which I've collected into an array/list, and now I want to combine those OR-wise into a NEST query using MatchPhrase. How would I do that? The code for a (single) search term would look something like this: var search = client.Search<ElasticRequirement>(s...

NEST v1.0.2 compatibility with elasticsearch 1.4

elasticsearch,nest
I am currently using NEST v1.0.2 with elasticsearch v1.3.2. I would like to upgrade elasticsearch to 1.4 without having to change my application's NEST dependencies, but I am having trouble finding any information about compatibility of the client APIs with more mature versions of elasticsearch. Does anyone know if these...

ElasticSearch Nest Query with Dynamic Match

elasticsearch,nest
I want to build an ElasticSearch Nest SearchDescriptor dynamically using conditional Match. The UI has two check boxes "Exclude Email" and "Exclude Loose Files". If both are checked, the search result will match 0 hits. These 4 queries work, but I can't figure out how to make the Match parts...

NEST ElasticSearch Delete type

.net,nest
I will be very grateful if someone tells me the correct way to delete all data in specific type using NEST. I have one index in my elasticsearch and two types and I would like to be able to delete all data in one or the other type when I...

Getting distinct values using NEST ElasticSearch client

c#,.net,elasticsearch,nest
I'm building a product search engine with Elastic Search in my .NET application, by using the NEST client, and there is one thing i'm having trouble with. Getting a distinct set of values. I'm search for products, which there are many thousands, but of course i can only return 10...

How to exclude inherited object properties from mappings

elasticsearch,nest
I'm trying to setup a mapping for an object that looks like this: class TestObject { public long TestID { get; set; } [ElasticProperty(Type = FieldType.Object)] public Dictionary<long, List<DateTime>> Items { get; set; } } I use the following mapping code (where Client is IElasticClient): this.Client.Map<TestObject>(m => m.MapFromAttributes()); I get...

ElasticSearch NEST: Create an index through ElasticClient by specifying json

c#,elasticsearch,nest
We allow the client to define custom analyzers at the time they create an index. We would prefer to specify this in json to provide maximum flexibility and understandability via the underlying ElasticSearch documentation. I would like to create an index using an arbitrary description of analyzers, mappers, etc., defined...