elasticsearch-dsl

Elasticsearch: Save aggregations query into CSV file

不问归期 提交于 2020-06-29 03:55:06
问题 I have data such as: { "_index": "user_log", "_type": "logs", "_id": "gdUJpXIBAoADuwvHTK29", "_score": 1, "_source": { "user_id": 105, "user_name": "prathameshsalap@gmail.com", "working_hours": "2019-10-21 09:00:01", "date": "2019-10-21", "working_minutes": 540 } { "_index": "user_log", "_type": "logs", "_id": "gtUJpXIBAoADuwvHTK29", "_version": 1, "_score": 0, "_source": { "user_id": 106, "user_name": "vaishusawant143@gmail.com", "working_hours": "2019-10-21 09:15:01", "date": "2019-10-21",

What is the Elasticsearch-py equivalent to alias actions?

好久不见. 提交于 2020-05-25 13:30:59
问题 I am trying to implement multiples indices approach using elasticsearch-dsl. There are basically two steps: 1. Create aliases: PUT /tweets_1/_alias/tweets_search PUT /tweets_1/_alias/tweets_index 2. Change alias when necessary: POST /_aliases { "actions": [ { "add": { "index": "tweets_2", "alias": "tweets_search" }}, { "remove": { "index": "tweets_1", "alias": "tweets_index" }}, { "add": { "index": "tweets_2", "alias": "tweets_index" }} ] } I could only implement the step 1 using

What is the Elasticsearch-py equivalent to alias actions?

人盡茶涼 提交于 2020-05-25 13:27:28
问题 I am trying to implement multiples indices approach using elasticsearch-dsl. There are basically two steps: 1. Create aliases: PUT /tweets_1/_alias/tweets_search PUT /tweets_1/_alias/tweets_index 2. Change alias when necessary: POST /_aliases { "actions": [ { "add": { "index": "tweets_2", "alias": "tweets_search" }}, { "remove": { "index": "tweets_1", "alias": "tweets_index" }}, { "add": { "index": "tweets_2", "alias": "tweets_index" }} ] } I could only implement the step 1 using

Elasticsearch query to return all records

☆樱花仙子☆ 提交于 2020-03-29 04:46:10
问题 I have a small database in Elasticsearch and for testing purposes would like to pull all records back. I am attempting to use a URL of the form... http://localhost:9200/foo/_search?pretty=true&q={'matchAll':{''}} Can someone give me the URL you would use to accomplish this, please? 回答1: I think lucene syntax is supported so: http://localhost:9200/foo/_search?pretty=true&q=*:* size defaults to 10, so you may also need &size=BIGNUMBER to get more than 10 items. (where BIGNUMBER equals a number

Elasticsearch query to return all records

穿精又带淫゛_ 提交于 2020-03-29 04:42:07
问题 I have a small database in Elasticsearch and for testing purposes would like to pull all records back. I am attempting to use a URL of the form... http://localhost:9200/foo/_search?pretty=true&q={'matchAll':{''}} Can someone give me the URL you would use to accomplish this, please? 回答1: I think lucene syntax is supported so: http://localhost:9200/foo/_search?pretty=true&q=*:* size defaults to 10, so you may also need &size=BIGNUMBER to get more than 10 items. (where BIGNUMBER equals a number

Index CSV to ElasticSearch in Python

谁都会走 提交于 2020-01-12 02:00:31
问题 Looking to index a CSV file to ElasticSearch, without using Logstash. I am using the elasticsearch-dsl high level library. Given a CSV with header for example: name,address,url adam,hills 32,http://rockit.com jane,valleys 23,http://popit.com What will be the best way to index all the data by the fields? Eventually I'm looking to get each row to look like this { "name": "adam", "address": "hills 32", "url": "http://rockit.com" } 回答1: This kind of task is easier with the lower-level

Elasticsearch 2.4, Exists filter for nested objects not working

你离开我真会死。 提交于 2020-01-02 08:52:36
问题 My mapping is: "properties": { "user": { "type": "nested", "properties": { "id": { "type": "integer" }, "is_active": { "type": "boolean", "null_value": false }, "username": { "type": "string" } } }, I want to get all documents that do not have a user field. I tried: GET /index/type/_search { "query": { "bool": { "must_not": [ { "exists": { "field": "user" } } ] } } } Which returns all documents. Based on ElasticSearch 2.x exists filter for nested field doesn't work, I also tried: GET /index

How to access the response object using elasticsearch DSL for python

倾然丶 夕夏残阳落幕 提交于 2019-12-25 16:42:16
问题 I have the following code: s = Search(using=Elasticsearch('http://user:passwd@ipaddress'), index="myindex") q = Q("multi_match", query='some query', fields=['_all']) s = s.query(q) response = s.execute() print('Total %d hits found.' % response.hits.total) for hit in response: print(hit.title) And I get the error: Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/elasticsearch_dsl/utils.py", line 102, in __getattr__ return _wrap(self._d_[attr_name]) KeyError:

How to access the response object using elasticsearch DSL for python

倾然丶 夕夏残阳落幕 提交于 2019-12-25 16:41:57
问题 I have the following code: s = Search(using=Elasticsearch('http://user:passwd@ipaddress'), index="myindex") q = Q("multi_match", query='some query', fields=['_all']) s = s.query(q) response = s.execute() print('Total %d hits found.' % response.hits.total) for hit in response: print(hit.title) And I get the error: Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/elasticsearch_dsl/utils.py", line 102, in __getattr__ return _wrap(self._d_[attr_name]) KeyError:

Elasticsearch date query. People who were born in a certain month

▼魔方 西西 提交于 2019-12-24 11:26:51
问题 I have a field with the following mapping: birthdate: { type: :date, format: :dateOptionalTime } I need to find everyone who were born in month of May (including all years) Another query is to find all people who were born on 'August 25' (including all years) What would be the query for that? 回答1: You can achieve this with a script filter All people born in May of any year: { "query": { "filtered": { "filter": { "script": { "script": "doc.birthdate.date.monthOfYear == 5" } } } } } All people