ElasticSearch

Elastic Search Query for Distinct Nested Values

好久不见. 提交于 2021-02-11 14:32:34
问题 I am using the High Level REST Client for Elastic Search 6.2.2. Suppose that I have two documents in index "DOCUMENTS" with type "DOCUMENTS" that are { "_id": 1, "Name": "John", "FunFacts": { "FavColor": "Green", "Age": 32 } }, { "_id": 2, "Name": "Amy", "FunFacts": { "FavFood": "Pizza", "Age": 33 } } I want to find out all of the distinct fun facts and their distinct values, ultimately returning an end result of { "FavColor": ["Green"], "Age": [32, 33], "FavFood": ["Pizza"] } It is ok for

Migrating 3 million records from Oracle to Elastic search using logstash

让人想犯罪 __ 提交于 2021-02-11 14:24:50
问题 We are trying to migrate around 3 million records from oracle to Elastic Search using Logstash. We are applying a couple of jdbc_streaming filters as a part of our logstash script, one to load connecting nested objects and another to run a hierarchical query to load data to another nested object in the index. We are able to index 0.4 million records in 24 hours. The total size occupied by .4 million records is around 300MB. We tried multiple approaches to migrate data quickly into elastic

Kibana index pattern don't show data with time filter field name

血红的双手。 提交于 2021-02-11 14:21:58
问题 i am trying to create an index from Java code to index some data but if i am creating index pattern with time filter Kibana never shows any data. Following below order while creating index with some setting and adding an index template for date filed CreateIndexRequest request = new CreateIndexRequest(indexName); request.settings(Settings.builder() .put("index.max_inner_result_window", 250) .put("index.write.wait_for_active_shards", 1) .put("index.query.default_field", "paragraph") .put(

How to use an ngram and edge ngram tokenizer together in elasticsearch index?

大兔子大兔子 提交于 2021-02-11 14:21:38
问题 I have an index containing 3 documents. { "firstname": "Anne", "lastname": "Borg", } { "firstname": "Leanne", "lastname": "Ray" }, { "firstname": "Anne", "middlename": "M", "lastname": "Stone" } When I search for "Anne", I would like elastic to return all 3 of these documents (because they all match the term "Anne" to a degree). BUT, I would like Leanne Ray to have a lower score (relevance ranking) because the search term "Anne" appears at a later position in this document than the term

ElasticSearch query string search date by range in nested object

☆樱花仙子☆ 提交于 2021-02-11 14:16:07
问题 Suppose I have documents that have this kind of structure { "_index": "unittest_repositorydb_iscatalogdata_v2", "_type": "product", "_id": "Product_100092_In_81810", "_score": 2.0794415, "_source": { "p": { "effective_dt": null, "code_s_lower": "B19_9394_Exp", "expiration_dt": "2020-05-16T00:00:00.0000000Z" }, "catId_s": "fNXXb5CRkpM" } } What I want to do is search by expiration date using query string. This is the query I do in Kibana: GET _search { "query": { "query_string": { "query":

ElasticSearch logger, log entire source on error

六眼飞鱼酱① 提交于 2021-02-11 13:53:57
问题 I'm trying to get extra information from ElasticSearch's logger on MapperParsingException. The error message looks like [logs-X][1] failed to execute bulk item (index) index {[logs-X][logs][x], source[n/a, actual length: [2.9kb], max length: 2kb]} It shows source[n/a.. Is there a way to print the actual source? 回答1: It's not possible, at least by configuration There is a constant value set: https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/action

elasticsearch query_string handle special characters

六眼飞鱼酱① 提交于 2021-02-11 13:47:40
问题 My database is sync with an Elasticsearch to optimize our search results and request faster. I have an issue querying the users, I want with a query therm look for my users, it can be part of a name, phone, ip, ... My actual query is query_string: { fields: ['id', 'email', 'firstName', 'lastName', 'phone', 'ip'], query: `*${escapeElastic(req.query.search.toString().toLowerCase())}*`} Where req.query.search is my search and escapeElastic comes from the node module elasticsearch-sanitize

How to get the number of documents for each occurence in Elastic?

不想你离开。 提交于 2021-02-11 13:45:27
问题 I have an Elastic index (say file ) where I append a document every time the file is downloaded by a client. Each document is quite basic, it contains a field filename and a date when to indicate the time of the download. What I want to achieve is to get, for each file the number of times it has been downloaded in the last 3 months. For the moment, the closest I get it with this query: { "query": { "range": { "when": { "gte": "now-3M" } } }, "aggs": { "downloads": { "terms": { "field":

What is the best practice of fuzzy search (like '%aaa%' in MySQL) in Elasticsearch 6.8

一曲冷凌霜 提交于 2021-02-11 13:41:32
问题 Background: I use Mysql and there are millions data, each line have twenty columns, we have some complex search and some column use fuzzy match, such as username like '%aaa%' , it can't use mysql index unless remove the first % , but we need fuzzy match to do search like Satckoverflow search, i also checked Mysql fulltext index , but it doesn't support complex search whthin one sql if using other index. My solution: add Elasticsearch as our search engine, insert data into Mysql and Es and

How to search on Elasticsearch for words with or without apostrophe ? and deal with spelling mistakes?

会有一股神秘感。 提交于 2021-02-11 13:38:48
问题 I'm trying to move my Full Text Search logic from MySQL to Elasticsearch. In MySQL to find all rows containing the word "woman" I would just write SELECT b.code FROM BIBLE b WHERE ((b.DISPLAY_NAME LIKE '%woman%') OR (b.BRAND LIKE '%woman%') OR (b.DESCRIPTION LIKE '%woman%')); on elasticsearch I tried for something similar curl -X GET "localhost:9200/bible/_search" -H 'Content-Type: application/json' -d' { "query": { "multi_match": { "query": "WOMAN","fields": ["description","display_name",