Category : elasticsearch-dsl-py

I have a elasticsearch cluster with 3 nodes. here is stats output: {"_nodes": {"total": 3, "successful": 3, "failed": 0}} The index has 3 shards and 2 replicas. I use elasticsearch-dsl==7.4.0 in python django app. ELASTIC = { "hosts": ["hostname1:9200","hostname2:9200","hostname3:9200"], "timeout": 10, "max_retries": 0, } connections.configure(default=ELASTIC) sometimes save to index or search elasticsearch returnes this exception: ..

Read more

I have a user specific json, that provides info as to what fields and documents should be accessible by particular user for a particular index. Now whenever that user tries to load that index in python workspace using elasticsearch-py client, they should only be able to access and modify those fields and documents and not ..

Read more

I have the following query which is working fine, test it in kibana with my data: GET my_index/_search?size=0 { "aggs": { "geo_bounding_box": { "filter": { "geo_bounding_box": { "location": { "top_left": { "lat": 38.2715027604674, "lon": -121.925823154605 }, "bottom_right": { "lat": 37.2876652395326, "lon": -122.91285484539499 } } } }, "aggregations": { "AggregationGeotileGridBuckets": { "geotile_grid": { "field": "location", "precision": ..

Read more

Using ElasticSearch 6.x and elasticsearch-dsl python package I have a list of fields fields = [‘field_1’, ‘field_2’] and I am trying to build a leaf match query using the following method from elasticsearch_dsl.query import MultiMatch, Match, ConstantScore def _get_match(tokens, fields, boost): for index in range(len(fields)): field = fields[index] print(Match(field={"query": tokens[index], "boost": boost})) tokens = [‘token_1’, ..

Read more

I wrote this below method to filter data for last 8 days def method_one(query) -> Query: gte = (datetime.datetime.now() – datetime.timedelta(days=query)).date() lt = (datetime.datetime.now()).date() print(gte, lt) return Q(MultiMatch( query=filter("range", {"lastModifiedDate": {"gte": gte, "lt": lt}} ), fields=[‘lastModifiedDate’] )) I want to filter data based on the lastModifiedDate field by forming an Elasticsearch Query object in Python. ..

Read more

My goal is to sort millions of logs by timestamp that I receive out of elastic. Example logs: {"realIp": "192.168.0.2", "@timestamp": "2020-12-06T02:00:09.000Z"} {"realIp": "192.168.0.2", "@timestamp": "2020-12-06T02:01:09.000Z"} {"realIp": "192.168.0.2", "@timestamp": "2020-12-06T02:02:09.000Z"} {"realIp": "192.168.0.2", "@timestamp": "2020-12-06T02:04:09.000Z"} Unfortunately, I am not able to get all the logs sorted out of Elastic. It seems like I have to do ..

Read more

My goal is to sort millions of logs by timestamp that I receive out of Elasticsearch. Example logs: {"realIp": "192.168.0.2", "@timestamp": "2020-12-06T02:00:09.000Z"} {"realIp": "192.168.0.2", "@timestamp": "2020-12-06T02:01:09.000Z"} {"realIp": "192.168.0.2", "@timestamp": "2020-12-06T02:02:09.000Z"} {"realIp": "192.168.0.2", "@timestamp": "2020-12-06T02:04:09.000Z"} Unfortunately, I am not able to get all the logs sorted out of Elastic. It seems like I have to do ..

Read more