Questions tagged [elasticsearch-dsl-py]

Elasticsearch DSL is a high-level Python library whose aim is to help with writing and running queries against Elasticsearch.

It provides a more convenient and idiomatic way to write and manipulate queries. It stays close to the Elasticsearch JSON DSL, mirroring its terminology and structure. It exposes the whole range of the DSL from Python either directly using defined classes or a queryset-like expressions.

It also provides an optional wrapper for working with documents as Python objects: defining mappings, retrieving and saving documents, wrapping the document data in user-defined classes.

148 questions
0
votes
0 answers

Filter rows based on a pair of conditions in Elasticsearch in Django

I'm working on a QA (survey) application. I have implemented Elastic Search in the application. I want to filter users based on their answers. Suppose, there are questions: Do you have a passport? Yes/No Do you have a driving license? Yes/No Now I…
0
votes
1 answer

Elasticsearch document -- what does the "input" key do?

I am working in a legacy codebase, and I have documents that are being indexed in ElasticSearch that look like the below image. I am trying to determine what feature or functional part of ElasticSearch is being used in the image below, with these…
Brian Peterson
  • 2,800
  • 6
  • 29
  • 36
0
votes
2 answers

select a single field with applying filters in elasticsearch

I would like to select all the filename field values by ACCOUNT and APPLICATION_NAME Assuming as in SQL I need to do this : select filename.keyword from XXX where ACCOUNT='monitoring' and APPLICATION_NAME='webapp' this is a screenshot of a log…
Shima Mahmoud
  • 49
  • 1
  • 10
0
votes
0 answers

search_phase_execution_exception, failed to create query

I am using elasticsearch-dsl in my django project. Elasticsearch is totally new for me and at some point i got this error: error So i started debugging and removing some part of my code. But here i am my code has become extremely simple but i still…
0
votes
0 answers

Updating Elasticsearch Query parameter in Python

I am querying elasticsearch in python. I want to change a parameter 'default operator' in case query returns zero values. Here's my code: default_operator = "and" if searchfields is not None: if query is not None and query != '': …
0
votes
0 answers

Elasticsearch cluster gives READTIMEOUT error

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":…
0
votes
1 answer

elasticsearch python client set size to 0 for aggregation

I want to run query using python elasticsearch client GET /employee-index/_search { "size":0, "aggs": { "genres": { "terms": { "field": "gender.keyword" } } } } This is what I am doing but it is returning me the records es =…
harshit
  • 7,925
  • 23
  • 70
  • 97
0
votes
1 answer

How to search nested Doc in Elasticsearch_dsl

I have multiple indices on of them called Post with Nested document Comment. this is how my documents defined class CommentDoc(InnerDoc): title = Text(analyzer=ngram_analyzer) content = Text(analyzer=ngram_analyzer) class PostDoc(Document): …
Mostafa A
  • 53
  • 2
0
votes
1 answer

Python elasticsearch-dsl build match query dynamically

Using ElasticSearch 6.x and elasticsearch-dsl python package I am trying to generate a match query with its options form, with the query element. I have a list of fields fields = ['field_1', 'field_2'] and I am trying to build a leaf match query…
0
votes
1 answer

Elasticsearch DSL update by scan?

Is it possible to update with the scan() method from Python's elasticsearch-dsl library? For example: search = Search(index=INDEX).query(query).params(request_timeout=6000) print('Scanning Query and updating.') for hit in search.scan(): _id =…
spitfiredd
  • 2,897
  • 5
  • 32
  • 75
0
votes
1 answer

Filter data by day range in Elasticsearch using Python DSL

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…
JustCode
  • 41
  • 1
  • 12
0
votes
2 answers

How to perform an exact match of field when each field is within a list in Elasticsearch

Sample of the data present in my ES index : { "entities" : [ { "fieldName" : "abc" }, { "fieldName" : "def" } ], "entities" : [ { "fieldName" : "abc" }, { "fieldName" : "def" } ], …
0
votes
1 answer

Django-Elasticsearch-DSL Nested Range Query

I'm trying to implement the following Elasticsearch query using django-elasticsearch-dsl and am having some difficulty Query { "query":{ "nested":{ "path":"ip_addresses", "query":{ "bool":{ …
0
votes
1 answer

How can i change the _id for the document django elasticsearch dsl python

For thew document class i want to change to _id used to be a slug or another option @registry.register_document class TestDocument(Document): id = fields.IntegerField(attr='id', multi=True) name = fields.TextField( analyzer=html_strip, …
Hetdev
  • 1,425
  • 2
  • 21
  • 29
0
votes
1 answer

How can i do both search across all field and search with field specified in Elastic search?

I'm very new to elastic search, how do I write a query which search for a keyword (ie. test keyword) in all fields in the document, and one more keyword which search in a specific field. this can be done using query_string but we can't do search in…