elasticsearch-dsl-py

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",

elasticsearch_dsl: Generate multiple buckets in aggregation

痴心易碎 提交于 2019-12-23 02:49:09
问题 I want to generate this: GET /packets-2017-09-25/_search { "size": 0, "query": { "match": { "transport_protocol": "tcp" } }, "aggs": { "clients": { "terms": { "field": "layers.ip.src.keyword", "size": 1000, "order":{ "num_servers.value":"desc" } }, "aggs": { "num_servers": { "cardinality": { "field": "layers.ip.dst.keyword", "precision_threshold" : 40000 } }, "server_list": { "terms": { "field": "layers.ip.dst.keyword" } } } } } } i.e I want two buckets (num_servers) and (server_list) under

Elastic search query find exact match of values in the list from regexp input parameter

亡梦爱人 提交于 2019-12-11 14:49:42
问题 My data looks like below: { "name": "name1", "name_gr": ["gr1","gr2"] }, { "name": "name2", "name_gr": ["gr1","gr2"] }, { "name": "name3", "name_gr": ["gr2","gr3"] }, { "name": "name4", "name_gr": ["gr1","gr2","gr3","gr4"] }, { "name": "name4", "name_gr": ["gr4","gr5"] } Now, i am trying to write elastic search query using elasticsearch_dsl python module by importing Q from it. My input query will be some regex on "name_gr" . For eg: "name_gr": "gr[12]" . So, in this case I want all the names

elasticsearch-dsl-py Sorting by Text() field

删除回忆录丶 提交于 2019-12-11 13:24:55
问题 I have problem with .sort() method. For example I have Index with Text() field: FILTER = token_filter( 'FILTER', 'edge_ngram', min_gram=3, max_gram=40) ANALYZER = analyzer( 'ANALYZER', tokenizer='standard', type='custom', filter=[ 'standard', 'lowercase', 'stop', 'asciifolding',FILTER]) class Article(DocType): title = Text(analyzer=ANALYZER) body = Text(analyzer='snowball') tags = Keyword() search = Article.search().sort('title') search.execute() when I try to execute search query with sort I

elasticsearch_dsl: Generate multiple buckets in aggregation

▼魔方 西西 提交于 2019-12-06 15:47:05
I want to generate this: GET /packets-2017-09-25/_search { "size": 0, "query": { "match": { "transport_protocol": "tcp" } }, "aggs": { "clients": { "terms": { "field": "layers.ip.src.keyword", "size": 1000, "order":{ "num_servers.value":"desc" } }, "aggs": { "num_servers": { "cardinality": { "field": "layers.ip.dst.keyword", "precision_threshold" : 40000 } }, "server_list": { "terms": { "field": "layers.ip.dst.keyword" } } } } } } i.e I want two buckets (num_servers) and (server_list) under clients. I am trying the below piece of code, which errors out: def get_streams_per_client(proto='tcp',

negative lookahead Regexp doesnt work in ES dsl query

99封情书 提交于 2019-12-02 00:44:15
问题 The mapping of my Elastic search looks like below: { "settings": { "index": { "number_of_shards": "5", "number_of_replicas": "1" } }, "mappings": { "node": { "properties": { "field1": { "type": "keyword" }, "field2": { "type": "keyword" }, "query": { "properties": { "regexp": { "properties": { "field1": { "type": "keyword" }, "field2": { "type": "keyword" } } } } } } } } } Problem is : I am forming ES queries using elasticsearch_dsl Q(). It works perfectly fine in most of the cases when my

negative lookahead Regexp doesnt work in ES dsl query

狂风中的少年 提交于 2019-12-01 21:22:24
The mapping of my Elastic search looks like below: { "settings": { "index": { "number_of_shards": "5", "number_of_replicas": "1" } }, "mappings": { "node": { "properties": { "field1": { "type": "keyword" }, "field2": { "type": "keyword" }, "query": { "properties": { "regexp": { "properties": { "field1": { "type": "keyword" }, "field2": { "type": "keyword" } } } } } } } } } Problem is : I am forming ES queries using elasticsearch_dsl Q(). It works perfectly fine in most of the cases when my query contains any complex regexp. But it totally fails if it contains regexp character '!' in it. It