elasticsearch-dsl

Elasticsearch Query on indexes whose name is matching a certain pattern

雨燕双飞 提交于 2021-02-10 06:14:14
问题 I have a couple of indexes in my Elasticsearch DB as follows Index_2019_01 Index_2019_02 Index_2019_03 Index_2019_04 . . Index_2019_12 Suppose I want to search only on the first 3 Indexes. I mean a regular expression like this: select count(*) from Index_2019_0[1-3] where LanguageId="English" What is the correct way to do that in Elasticsearch? 回答1: How can I query several indexes with certain names? This can be achieved via multi-index search, which is a built-in capability of Elasticsearch.

Elasticsearch Query on indexes whose name is matching a certain pattern

社会主义新天地 提交于 2021-02-10 06:14:08
问题 I have a couple of indexes in my Elasticsearch DB as follows Index_2019_01 Index_2019_02 Index_2019_03 Index_2019_04 . . Index_2019_12 Suppose I want to search only on the first 3 Indexes. I mean a regular expression like this: select count(*) from Index_2019_0[1-3] where LanguageId="English" What is the correct way to do that in Elasticsearch? 回答1: How can I query several indexes with certain names? This can be achieved via multi-index search, which is a built-in capability of Elasticsearch.

Include parent _source fields in nested top hits aggregation

随声附和 提交于 2021-01-28 21:13:22
问题 I am trying to aggregate on a field and get the top records using top_ hits but I want to include other fields in the response which are not included in the nested property mapping. Currently if I specify _source:{"include":[]} , I am able to get only the fields which are in the current nested property. Here is my mapping { "my_cart":{ "mappings":{ "properties":{ "store":{ "properties":{ "name":{ "type":"keyword" } } }, "sales":{ "type":"nested", "properties":{ "Price":{ "type":"float" },

Elasticsearch - Choosing the analyzer to use for fields

流过昼夜 提交于 2021-01-28 14:04:44
问题 How do I tell query_string which analyzer to use in a search? I've created my index with an analyzer like so: "analysis": { "analyzer": { "std_analyzer": { "tokenizer": "whitespace", "filter": [ "stemmer" ] } } } I do not predefine any mappings. Instead, I rely mappings to be dynamically added upon inserting a document. The mappings appear like so after calling /my_index/_mapping "short_bio" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, You

Is there is any way to iterate elastic array document like other programming language with script

冷暖自知 提交于 2021-01-27 15:42:35
问题 Mapping { "supply": { "properties": { "rotation_list": { "type": "nested", "properties": { "project_end_date": { "type": "nested", "properties": { "end_date": { "type": "date", "format": "yyyy-MM-ddTHH:mm:ss" } } }, "total_days": { "type": "integer" } } } } }} Data {"rotation_list": [ { "project_end_date": [ { "end_date": "2020-08-07" }, { "end_date": "2020-06-07" } ], "total_days": 23 }, { "project_end_date": [ { "end_date": "2020-08-07" } ], "total_days": 26 }]} query {"query": { "bool": {

Index JSON files in elasticsearch using Python?

大兔子大兔子 提交于 2020-07-06 17:42:27
问题 I have a bunch of JSON files(100), which are named as merged_file 1.json, merged_file 2. json and so on. How do I index all these files into elasticsearch using python(elasticsearch_dsl) ? I am using this code, but it doesn't seem to work: from elasticsearch_dsl import Elasticsearch import json import os import sys es = Elasticsearch() json_docs =[] directory = sys.argv[1] for filename in os.listdir(directory): if filename.endswith('.json'): with open(filename,'r') as open_file: json_docs

Django elasticsearch DSL DRF suggetions issue

余生长醉 提交于 2020-06-29 04:58:09
问题 I am implementing Django elasticsearch DSL DRF in my project to create rest API for elasticsearch. Elastic search is working fine but having the issue in search suggestions. As per documentation if I use the suggest in URL then it gives error screen. But I don't add that then I got an incorrect response. I am attaching screenshots of my code. enter image description here enter image description here document code enter image description here view code enter image description here Code for