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
2
votes
0 answers

How do you sum a scripted field using Python's elasticsearch_dsl Search?

This works for me correctly: search = Search(using=client, index='my_index').script_fields( special={'script': { 'source': ""} } ) And now I want to attach a sum the field special across all hits. I…
2
votes
0 answers

Elasticsearch From and Size on aggregation for pagination

First of all, I want to say that the requirement I want to achieve is working very well on SOLR 5.3.1 but not on ElasticSearch 6.2 as a service on AWS. My actual query is very large and complex and it is working fine on kibana but not when I cross…
2
votes
1 answer

How does one keep an Elasticsearch index up-to-date using elasticsearch-dsl-py?

I developed a small personal information directory that my client accesses and updates through a Django admin interface. That information needs to be searchable, so I set up my Django site to keep that data in a search index. I originally used…
coredumperror
  • 8,471
  • 6
  • 33
  • 42
2
votes
2 answers

Using shingles and fuzziness in Elasticsearch Python DSL?

How do you call shingles in Python DSL? This is a simple example that searches for a phrase in the "name" field and another one in the "surname" field. import json from elasticsearch import Elasticsearch from elasticsearch_dsl import Search, Q def…
1
vote
0 answers

Filtering on multiple fields in an Elasticsearch ObjectField()

I am having trouble figuring out the filtering syntax for ObjectFields() in django-elasticsearch-dsl. In particular, when I try to filter on multiple subfields of the same ObjectField(), I'm getting incorrect results. For example, consider the…
Ender
  • 95
  • 9
1
vote
2 answers

How do I create a runtime field with elasticsearch-dsl?

I have been successfully using python with elasticsearch-dsl (https://elasticsearch-dsl.readthedocs.io/en/latest/search_dsl.html#) and composite aggregations for some time now but have come across a problem I can't solve. The data I'm querying is…
RonR
  • 298
  • 1
  • 13
1
vote
2 answers

Searching through objects inside nested documents provides unexpected output

I am getting unexpected result from Elasticsearch while searching though object property which are inside nested property. I am using elasticsearch-dsl python library for creating document and querying. Is this bug or I am missing something in…
1
vote
1 answer

Elasticsearch DSL. Build bounding box filter inside aggregation

I need build geotitle_grid aggregation with geo_bounding_box Here is my code: search_query: DslSearch = DslSearch() enriched_value = { "aggregations": { "AggregationGeotileGridBuckets": { "geotile_grid": { …
1
vote
0 answers

Best practice for sharing models definition across containers in docker-compose?

There are multiple containers using data from the same indexes in Elasticsearch and Mongodb databases: app is a python app that serves data via API tasks is a python + celery app that perform periodical updates, cleaning, etc. on the same…
funkifunki
  • 1,149
  • 2
  • 13
  • 24
1
vote
1 answer

Search Nested Fields on Elasticsearch DSL DRF

This is document.py @chapter_index.doc_type class ChapterDocument(Document): subject = fields.ObjectField(properties={ 'name': fields.TextField(), 'description': fields.TextField() }) topics =…
1
vote
2 answers

How to sort paginated logs by @timestamp with Elasticsearch?

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

Elasticsearch nested field not exist query in DSL python

I have a nested data mapping in a document and I want to query if a nested field does not exist. This elastic query is working but what will be the elastic DSL representation on this query? GET products/_search { "query": { "bool": { …
frfahim
  • 515
  • 9
  • 21
1
vote
0 answers

Using a single query for multiple searches in ElasticSearch

I have a dataset with documents that are identifiable by three fields, let's say "name","timestamp" and "country". Now, I use elasticsearch-dsl-py, but I can read native elasticsearch queries, so I can accept those as answers as well. Here's my code…
1
vote
1 answer

Elasticsearch Date histogram aggregation without considering year

I want to aggregate data with respect to month and date, I'm trying with date histogram aggregation but its considering full date object. I have data like: { "created" : "2020-09-26", "id" : 6, "name" : "Halum…
1
vote
1 answer

How to use bucket, metric or pipeline in elasticsearch dsl (elasticsearch-dsl-py) for multiple layers of aggregations

I have a raw aggregation script like below, but have hard time to convert it into elasticsearch dsl. I've read the document and found the description saying that we may use the .bucket(), .metric() and .pipeline() methods for nesting aggregations…
SoniaWu
  • 21
  • 4
1 2
3
9 10