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
1
vote
0 answers

Filter on inner object in Elasticsearch returns 0 results

I run the following query on Elasticsearch 1.5, constructed with elasticsearch-dsl in python, and it returns 0 results. I do the same search using Kabana, and I get more than 1000 results. What am I doing…
lgunsch
  • 71
  • 5
1
vote
1 answer

Get @timestamp value in elasticsearch response

I'm using elasticsearch-dsl-py to extract data from elasticsearch. I want to save the value of the @timestamp field (hits.hits._source.@timestamp). But I have no clue how to deal with the fact that the @ character is not allowed in Python. How do I…
0
votes
0 answers

Index through multiple models through django-elasticsearch-dsl

I am trying to create an index which would be used to autocomplete, and basically stores the aggregation of three model field These are my models below class SmallShop(models.Model): small_name = models.TextField(blank=True, null=True) …
0
votes
0 answers

Get ElasticSearch suggestion based on filtered data in Django

I am using django-elasticsearch-dsl for integrating elastic search. I have an API that returns name suggestions using elastic search suggest feature. It's working as expected but the issue is I can't apply a specific filter. For example, I want to…
0
votes
0 answers

python elasticsearch DSL: Change aggregation size after initilization

In part A of my application I build a bunch of aggregations for later possible use in a query like this: from elasticsearch_dsl import A a = A("terms", field="some_field", size=10) In part B of the application, I want to change the size of these…
vlz
  • 911
  • 1
  • 10
  • 18
0
votes
0 answers

Elasticsearch DSL (python) Aggregation: Calculating Unique Days of Activity from Timestamp

I'm currently working with a dataset that includes Facebook posts and I'm attempting to implement an aggregation using Elasticsearch. Specifically, I want to bucket the data by user using the 'terms' aggregation with the 'author_id' field. Here's my…
0
votes
1 answer

Partial text-formatted date match with Elasticsearch regexp

I formatted a date field dob as text dob.strftime("%m/%d/%Y") and stored these dates on Elasticsearch 8.7.1 ("lucene_version": "9.5.0") so I could utilize regexp to do partial date matching. Suppose this date is stored on Elasticsearch: 06/01/2023,…
0
votes
1 answer

How to filter the buckets that have more than N documents using ElasticSearch DSL in python?

I have an index in ElasticSearch that contains information of a user in each document, along with the facebook posts they have made (in a denormalized manner). Each document contains: User_ID | User_Name | Post_Text | Post_Emojis I want to retrieve…
0
votes
0 answers

How to update the range filter from an existing string query using elasticsearch-dsl

I have below raw elasticsearch query in which i want to change the @timestamp range. import json from elasticsearch_dsl import Search query = """ { "query": { "range": { "@timestamp": { "gte": "now-1d/d", "lt": "now/d" …
Sirish
  • 9,183
  • 22
  • 72
  • 107
0
votes
0 answers

Use Elasticsearch dsl python in order to Query a field that has a colon

I use elasticsearch dsl python client in order to implement queries and run them against an ElasticSearch endpoint. A successfull example of such query would be the following: Search.filter("term", properties__grid=) which…
0
votes
1 answer

Searching through an array in an Elasticsearch field

I have a collection of Elasticsearch documents that look something like this: { "_score": 1, "_id": "inv_s3l9ly4d16csnh1b", "_source": { "manufacturer_item_id": "OCN1-1204P-ARS4", "description": "TLX Headlight", …
0
votes
0 answers

Elasticsearch truncate nested objects prior to retrieval

I have a nested field type called "authorships" (authors) that sometimes has a lot of nested objects. For example, some of the records have around 5,000 objects. Each object is fairly small. But when someone calls a set of 100 records these objects…
Casey
  • 2,611
  • 6
  • 34
  • 60
0
votes
1 answer

elasticsearch-dsl in python: How can I return the "inner hits" for my query?

I am currently exploring elasticsearch in python using the elasticsearch_dsl library. I am aware that my Elasticsearch knowledge is currently limited. I have created a model like so: class Post(InnerDoc): text = Text() id = Integer() class…
0
votes
0 answers

Failed to Fetch when the request didn't fail and code seemingly executes fine

I am using elasticsearch-dsl to construct 2 complex queries and execute them over multiple indices at the same time with MultiSearch. It is working fine in 99% of cases but rarely fails for some input parameters with such an error printed on backend…
Nikita Vlasenko
  • 4,004
  • 7
  • 47
  • 87
0
votes
1 answer

How to get results of kibana visualize library table using elasticserach-dsl-py

I want to make a function that will take as arguments a list of hostnames and a list of fields and dynamically prepare an efficient query to elasticserach to retrieve the last values for that fields for every host passed. The same way as I can do it…