elasticsearch-5

Mappings on filed Elastic Search

∥☆過路亽.° 提交于 2020-01-07 02:47:05
问题 I am using elastic search for autocompletion and also to correct spelling mistakes.I have this mapping for my field(for auto-completion). **Mapping:** "name": { "type": "text", "analyzer": "autocomplete" } Now i want to implement phrase suggester on this field.When i use this it is giving wrong result.Thats because of existing mapping i think. **POST XYZ/_search** { "suggest": { "text": "ipone 16", "simple_phrase": { "phrase": { "field": "name", "highlight": { "pre_tag": "<em>", "post_tag": "

Combine must and should

淺唱寂寞╮ 提交于 2020-01-05 08:13:11
问题 I've some troubles with an elasticsearch query. (I use elasticsearch 5). I want to combine must bool query and should in order to create a query which match this condition : Get users which match (city = x) AND (school = y) AND (age = 12) AND (team = a OR b) I tried many queries but I still have a query malformed exception. { "query": { "bool": { "must" : [ { "match": { "city": "x" } }, { "match" : { "school" : "y" } }, { "match" : { "age" : 12 }, "bool": { "should": [ {"term": {"team": "A"}}

How do I add a weight (or prefilter) for a phrase suggester?

♀尐吖头ヾ 提交于 2020-01-03 03:43:11
问题 I am new to phrase suggester and have been reading the docs. The completion suggester has a way to add a weight so that the results are scored. The phrase suggester has no such option unless I am missing. I have: POST test/_search { "suggest": { "text": "noble prize", "simple_phrase": { "phrase": { "field": "title.trigram", "size": 1, "gram_size": 3, "direct_generator": [ { "field": "title.trigram", "suggest_mode": "always" } ], "highlight": { "pre_tag": "<em>", "post_tag": "</em>" } } } } }

Content-Type header [application/x-www-form-urlencoded] is not supported [duplicate]

对着背影说爱祢 提交于 2020-01-01 04:43:08
问题 This question already has answers here : Content-Type header [application/x-www-form-urlencoded] is not supported on Elasticsearch (2 answers) Closed last year . I have integrated Elasticsearch (Version 5.5) into Gitlab and try to use it. This is the command I send from an external windows client: curl -XGET gitlab.server:9200/ -H 'Content-Type: application/json' -d '{"query": {"simple_query_string" : {"fields" : ["content"], "query" : "foo bar -baz"}}}' but it doesn't work. On the client I

What's the fastest manner to retrieve min timestamp from Elasticsearch indices?

余生长醉 提交于 2019-12-25 03:42:16
问题 In my opinion, there are two ways to implement it. But I don't know which is faster, because I don't have much data to test. Like SQL below: SELECT min(occur_time) FROM event_* SELECT occur_time FROM event_* order by occur_time limit 1 回答1: You can run a query, with size:1, sorted by @timestamp ascending, and even include_fields:@timestamp in order to fetch back only the minimum timestamp field: { "size":1, "sort": [{"@timestamp":"asc"}], "_source": { "includes": [ "@timestamp" ] } } 来源:

Elastic search- search exact matching string using query UI

戏子无情 提交于 2019-12-24 19:09:01
问题 Here is my JSON . { "id":100, "name":"xxx", "hobbies":["cricket","footbal","singing & dancing"] } I need to filter "singing & dancing" string from "others". Executed below query. http://localhost:9200/employeed/data/_search?q={"query":{"query_string":{"query" : "hobbies:Singing & dancing"}}} I am getting below exception. "type": "illegal_argument_exception", "reason": "request [employee/data/_search] contains unrecognized parameter: [ Singing\"}}}]" Any help? 回答1: You're attempting to send a

How to properly handle multi words synonym expansion using elasticsearch?

拜拜、爱过 提交于 2019-12-24 15:14:37
问题 I have the following synonym expansion : suco => suco, refresco, bebida de soja What i want is to tokenize the search this way: Search for "suco de laranja" would be tokenized to ["suco", "laranja", "refresco", "bebida de soja"]. But i'm getting it tokenized to ["suco", "laranja", "refresco", "bebida", "soja"]. Consider that the " de " word is a stop word. And i want it to be ignored on the query like "bebida de laranja" becomes ["bebida", "laranja"]. But i don't want it to be considered on

Elasticsearch 5.4: Use normal and nested fields in same Painless script query?

落爺英雄遲暮 提交于 2019-12-24 09:44:08
问题 I have a mapping like this: { printings: { type: "nested", properties: { prop1: {type: "number"} } }, prop2: {type: "number"} } I then want to build a Painless query like this: "script": { "lang": "painless", "inline": "doc['prop1'] > (3 * doc['printings.prop2'])" } However testing this in Sense doesn't work. If I replace the nested prop2 with a simple number then it does work. Is there a way to access both root and nested props in a single scripted query? 回答1: You can try below query. {

ElasticSearch stat size_in_bytes different for identical indices

萝らか妹 提交于 2019-12-24 08:48:54
问题 In ElasticSearch 5.6, I have created multiple indices of the same 15k documents. Specifically, 4 that all share the same mapping, settings, and content. 3 of the 4 had index sizes ~1.0 GB. index_1 of the 4 has a size of 52 MB. I've compared searches across the 4 indices, and index_1 returns less documents than the others for identical searches. I've seen anywhere from 1% to 80% less documents per query. At this point, I don't trust the docs.count or the store.size_in_bytes on index_1 or the

How to load a index template file into elasticsearch when it starts up?

久未见 提交于 2019-12-23 12:02:11
问题 In elasticsearch v1.5, Index templates can be placed within the config location (path.conf) under the templates directory elasticsearch/config/templates . However, I found this template will not be loaded after I upgrade to v2.3 or v5.3. Is any way to load index template? https://www.elastic.co/guide/en/elasticsearch/reference/1.5/indices-templates.html 回答1: No other way in 2.x or 5.x. This has been removed starting with 2.0.0-beta1 version of Elasticsearch. This was documented here. And