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
4 answers

Elasticsearch DSL on Python fails to generate Score

I have an Elasticsearch database with several fields that can include name information and am attempting to search it like so: from elasticsearch import Elasticsearch from elasticsearch_dsl import Search client = Elasticsearch() s =…
1
vote
1 answer

Loop over all results from query using elasticsearch

I am working with the DSL for Elasticsearch in Python. My goal is to work with Elasticsearch response data in a loop as easily as possible using elasticsearch-dsl-py. import datetime import json from elasticsearch import Elasticsearch from…
1
vote
3 answers

Query timestamp range using elasticsearch-dsl-py

I have an elasticsearch range query that I'd like to translate into elasticsearch-dsl: Elasticsearch Python API {"range": {"@timestamp": {"gte": 1570258800000, "lte": 1571036400000, "format": "epoch_millis" …
1
vote
1 answer

elasticsearch-dsl library in python giving double results when using search.from_dict() method to construct query from dictionary syntax

Please find below my iPython shell statements: In [90]: s = Search(using=client, index='institutes') In [91]: s = s.filter('match_phrase',country__uri='canada').filter("nested", path="institutecourse_set", query=Q("match_phrase",…
1
vote
0 answers

How to highlight and get informations from elasticsearch-dsl search in django?

I'm using django-elasticsearch-dsl. I have already index datas and set up some queries on them. Here is an example of query in my views : q = HemisticheDocument.search().query(operation, field="value") Then after I have : listHem = [hit for hit in…
1
vote
1 answer

3-level nested bool queries with elasticsearch dsl

Using ES 6.1, Python 3, and elasticsearch-dsl, I've got docs with this mapping: "mappings": { "doc": { "properties": { "id": {"type": "text"}, "prop_a": {"type": "text"}, "prop_b": { …
kgeo
  • 412
  • 5
  • 19
1
vote
1 answer

Elasticsearch Aggregation with hamming distance of a phash

Trying to group together similar documents with matching keyword field values and phashes of their related images. At the moment I have the following which works well for exact matching phashes 'duplicate_docs': A('terms', …
1
vote
1 answer

Add a field in ElasticSearch using python with boolean datatype?

How do add a new field of a particular datatype(boolean) in Elasticsearch using python. Is this query correct? es.update(index='my_index', doc_type='my_doctype', id='id_of_doc', body={"doc": {"new_field":"boolean_value"},"type":"boolean"})
1
vote
1 answer

Get result sorted by "@timestamp" in python using elasticsearch-dsl

I want get the data from my elasticsearch node for my code, i am using elasticsearch-dsl library to query the data from elasticsearch. Now i want the data to be sorted according to the "@timestamp" which can done using sort api. But the data that i…
1
vote
1 answer

Exception when trying to use Date in elasticsearch-dsl.py persistence api

I am trying to use persistence API, using elasticsearch-dsl version 6.2.1 as follow: class MyClass(Document): start = Date(format='dd-MM-yyyy HH:mm:ss:SSS') stop = Date(format='dd-MM-yyyy HH:mm:ss:SSS') When I call MyClass.init() I see…
miki
  • 13
  • 3
1
vote
0 answers

how to search in n element elastic-search-dsl

I've a problem in elastic search to know if an element already exist, because for a lot of practical reason I store in elastic-search meta data of image for each user (the author) and to avoid some attack I need to be sure that the image hasn't be…
1
vote
1 answer

sum calculation using elasticsearch-dsl python client

I have an Eleaticsearch index named 'demoadmin' with type named 'billing'. I have executed this following query body using POST successfully . {"query": { "filtered":{ "query" : {"match_all": {}}, "filter": { "bool": { "must":[{ "term": { "Month":…
1
vote
2 answers

elasticsearch-dsl search works only in debug mode

I am using the elasticsearch-dsl package in Python for my project. I have a very simple search query as can be seen below: s = Search(using=connections.get_connection(), index= 'registry', doc_type=['storage_doc']).params(request_timeout=60) …
Dimitris
  • 2,030
  • 3
  • 27
  • 45
1
vote
1 answer

elasticsearch-dsl-py Sorting by Text() field

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

Elasticsearch DSL multi level parent query

I'm using Elastisearch 5.x and Python with elasticsearch-dsl 5.2.0 I need to start querying from the Child, take a couple of fields, match it with a defined Father and Grandfather (from which Grandfather I also need a field value) The problem is…