ElasticSearch

Simple query string with special characters such as ( and =

天大地大妈咪最大 提交于 2021-02-19 07:43:25
问题 This is my index PUT /my_index { "settings": { "number_of_shards": 1, "number_of_replicas": 0, "analysis": { "filter": { "my_ascii_folding": { "type" : "asciifolding", "preserve_original": "true" } }, "analyzer": { "include_special_character": { "type": "custom", "filter": [ "lowercase", "my_ascii_folding" ], "tokenizer": "whitespace" } } } } } This is my mapping: PUT /my_index/_mapping/formulas { "properties": { "content": { "type": "text", "analyzer": "include_special_character" } } } My

Elasticsearch: get for a substring in the value of a document field?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-19 03:20:33
问题 In mysql I can use the sql SELECT LEFT(field,4) from table to search 4 bytes of a field. Elasticsearch has similar grammar? 回答1: With ES, you can use script_fields in order to perform any script computation on existing fields. In your case, this would translate to making a query like this: { "query" : { "match_all": {} }, "script_fields" : { "left_field" : { "script" : { "inline": "doc.field.value.substring(0, length)" "params": { "length": 4 } } } } } Then in your response you'll get a field

Elasticsearch: get for a substring in the value of a document field?

雨燕双飞 提交于 2021-02-19 03:20:01
问题 In mysql I can use the sql SELECT LEFT(field,4) from table to search 4 bytes of a field. Elasticsearch has similar grammar? 回答1: With ES, you can use script_fields in order to perform any script computation on existing fields. In your case, this would translate to making a query like this: { "query" : { "match_all": {} }, "script_fields" : { "left_field" : { "script" : { "inline": "doc.field.value.substring(0, length)" "params": { "length": 4 } } } } } Then in your response you'll get a field

MongoDB 4.x Real Time Sync to ElasticSearch 6.x +

喜夏-厌秋 提交于 2021-02-19 02:56:06
问题 I'm trying to find an easy way to sync data in mongoDB 4.x, to elasticsearch 6.x . My use case is for partial text search that is supported by elasticsearch but no supported by mongodb. MongoDB is the primary database for my applications. All solutions i found seem outdated and only support older version of mongoDB / elasticsearch. These include mongodb-connector, mongodb river What is the best tool to use so that any changes (CRUD) to data in mongoDB is automatically synced to elasticsearch?

Spring Data Elasticsearch's ElasticsearchTemplate vs ElasticsearchRepository

二次信任 提交于 2021-02-18 21:32:09
问题 I am in reference to Spring Data Elasticsearch's org.springframework.data.elasticsearch.repository.ElasticsearchRepository org.springframework.data.elasticsearch.core.ElasticsearchTemplate It seems they are two different APIs that achieve the same goal but I am not sure what the differences are between those two types and more importantly when to use which. Can someone please provide advice and guidance? 回答1: ElasticsearchRepository is intended to be used as a repository for your domain

Elasticsearch sort based on the number of occurrences a string appears in an array

半世苍凉 提交于 2021-02-18 19:35:48
问题 I have an array field containig a list of strings: ie.: ["NY", "CA"] At search time I have a filter which matches any of the strings in the array. I would like to sort the results based on documents that have the most number of appearances of the searched string: "NY" Results should include: document 1: ["CA", "NY", "NY"] document 2: ["NY", FL"] document 3: ["NY", CA", "NY", "NY"] Results should be ordered as such User 3, User 1, User 2 Is this possible? If so, how? 回答1: For those curious, I

Elastic Search (COUNT*) with group by and where condition

故事扮演 提交于 2021-02-18 15:00:08
问题 Dear Elastic Serach users, I am newbie in ElasticSearch. I am confused for how to convert the following sql command into elasticSearch DSL query ? Can anyone help to assist me. SELECT ip, count(*) as c FROM elastic WHERE date BETWEEN '2016-08-20 00:00:00' and '2016-08-22 13:41:09' AND service='http' AND destination='10.17.102.1' GROUP BY ip ORDER BY c DESC; THank YOu 回答1: The following query will achieve exactly what you want, i.e. it will select the documents within the desired date range

Is elasticsearch non-deterministic?

和自甴很熟 提交于 2021-02-18 12:31:33
问题 Does elasticsearch does not return the same results in the same order every time a query is executed because of its algorithm in calculating the score? Or is it something else? Is there a way to make it such that the results return in the same order everytime a query is executed? Is this normal? 回答1: This might to do with the way elastic search calculates relevancy scores locally by default. Try adding: &search_type=dfs_query_then_fetch to your query and see if that helps. This tells ES to

Is elasticsearch non-deterministic?

巧了我就是萌 提交于 2021-02-18 12:31:06
问题 Does elasticsearch does not return the same results in the same order every time a query is executed because of its algorithm in calculating the score? Or is it something else? Is there a way to make it such that the results return in the same order everytime a query is executed? Is this normal? 回答1: This might to do with the way elastic search calculates relevancy scores locally by default. Try adding: &search_type=dfs_query_then_fetch to your query and see if that helps. This tells ES to

Docker-compose links vs external_links

佐手、 提交于 2021-02-18 05:17:07
问题 I believe it is simple question but I still do not get it from Docker-compose documentations. What is the difference between links and external_links? I like external_links as I want to have core docker-compose and I want to extend it without overriding the core links. What exactly I have, I am trying to setup logstash which depends on the elasticsearch. Elasticsearch is in the core docker-compose and the logstash is in the depending one. So I had to define the elastic search in the depended