elasticsearch-net

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.net client can't do basic search

无人久伴 提交于 2019-12-04 08:59:18
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? If you use the low level client (elasticsearch.net) directly it will not do any normalisation and serialise the object verbatim: var

Elasticsearch aggregation. Order by nested bucket doc_count

不羁岁月 提交于 2019-12-02 05:04:54
What I want to achieve is aggregation by unique pairs (city, STATE). As per Elasticsearch documentation The terms aggregation does not support collecting terms from multiple fields in the same document . Thus I created a nested agg like this: { "size": 0, "aggs": { "cities": { "terms": { "field": "address.city", "size": 12 }, "aggs": { "states": { "terms": { "field": "address.stateOrProvince" }, "aggs": { "topCity": { "top_hits": { "size": 1, "sort": [ { "price.value": { "order": "desc" }}]}}}}}}}} As a result of this aggregation I get response like this: { "aggregations": { "cities": {

Like search in Elasticsearch

旧巷老猫 提交于 2019-11-30 13:15:58
问题 I am using elasticsearch for filtering and searching from json file and I am newbie in this technology. So I am little bit confused how to write like query in elasticsearch. select * from table_name where 'field_name' like 'a%' This is mysql query. How do I write this query in Elasticsearch? I am using elasticsearch version 0.90.7. 回答1: I would highly suggest updating your ElasticSearch version if possible, there have been significant changes since 0.9.x. This question is not quite specific

Like search in Elasticsearch

怎甘沉沦 提交于 2019-11-30 08:40:38
I am using elasticsearch for filtering and searching from json file and I am newbie in this technology. So I am little bit confused how to write like query in elasticsearch. select * from table_name where 'field_name' like 'a%' This is mysql query. How do I write this query in Elasticsearch? I am using elasticsearch version 0.90.7. I would highly suggest updating your ElasticSearch version if possible, there have been significant changes since 0.9.x. This question is not quite specific enough, as there are many ways ElasticSearch can fulfill this functionality, and they differ slightly on your

ElasticSearch NEST Query

左心房为你撑大大i 提交于 2019-11-28 09:29:35
I'm trying to mimic a query that I wrote in Sense (chrome plugin) using NEST in C#. I can't figure out what the difference between the two queries is. The Sense query returns records while the nest query does not. The queries are as follows: var searchResults = client.Search<File>(s => s.Query(q => q.Term(p => p.fileContents, "int"))); and { "query": { "term": { "fileContents": { "value": "int" } } } What is the difference between these two queries? Why would one return records and the other not? You can find out what query NEST uses with the following code: var json = System.Text.Encoding