Python's official low-level client for Elasticsearch
Questions tagged [elasticsearch-py]
194 questions
57
votes
1 answer
How to update a document using elasticsearch-py?
Does anyone have an example for how to use update? It's documented here, but the documentation is unclear and doesn't include a working example. I've tried the following:
coll =…

Dan Hook
- 6,769
- 7
- 35
- 52
48
votes
4 answers
python elasticsearch client set mappings during create index
I can set mappings of index being created in curl command like this:
{
"mappings":{
"logs_june":{
"_timestamp":{
"enabled":"true"
},
"properties":{
"logdate":{
"type":"date",
…
user4005632
21
votes
1 answer
Elasticsearch is not sorting the results
I'm having problem with an elasticsearch query.
I want to be able to sort the results but elasticsearch is ignoring the sort tag. Here my query:
{
"sort": [{
"title": {"order": "desc"}
}],
"query":{
"term": { "title":…

Alberto Menendez Romero
- 535
- 1
- 8
- 20
20
votes
2 answers
What is the Elasticsearch-py equivalent to alias actions?
I am trying to implement multiples indices approach using elasticsearch-dsl. There are basically two steps:
1. Create aliases:
PUT /tweets_1/_alias/tweets_search
PUT /tweets_1/_alias/tweets_index
2. Change alias when necessary:
POST /_aliases
{
…

Montenegrodr
- 1,597
- 1
- 16
- 30
15
votes
1 answer
Bulk update with Python's elasticsearch client
I'm attempting to do a bulk update based on state change on a document property. Create works fine but bulk is freaking out. I'm getting an error to the effect of "script or doc is missing" but everything looks good.
Here is how I am attempting the…

Obj3ctiv3_C_88
- 1,478
- 1
- 17
- 29
9
votes
1 answer
How to append to an array in Elasticsearch using elasticsearch-py
Using the Official ElasticSearch Python library (Docs)
I create an index:
doc = {
"something": "123a",
"somethingelse": "456b",
"timestamp": datetime.now(),
"history": []
}
es.index(index="someindex", doc_type="somedoctype",…

AO_
- 2,573
- 3
- 30
- 31
8
votes
3 answers
How do I create a (dockerized) Elasticsearch index using a python script running in a docker container?
I'm trying to index a containerized Elasticsearch db using the Python client https://github.com/elastic/elasticsearch-py called from a script (running in a container too).
By looking at existing pieces of code, it seems that docker-compose is a…

Davide Fiocco
- 5,350
- 5
- 35
- 72
7
votes
1 answer
Searching through multiple index yielding 0 documents in elasticsearch-py
I have a search query to make across multiple indexes. To enable this as per the documentation, I need to provide a comma-separated list of indexes.
But when I try to do it as: es.search(index='index1,index2',body=body)
I get no result:
{u'hits':…

Amogh Mishra
- 1,088
- 1
- 16
- 25
7
votes
2 answers
Usage of filter_path with helpers.scan in elastisearch client
When doing a search operation in elasticsearch i want the metadata to be filtered out and return only "_source" in the response. I'm able to achieve the same through "search" in the following way:
out1 = es.search(index='index.com',…

Jai Sharma
- 713
- 1
- 4
- 17
6
votes
2 answers
Add Timestamp to ElasticSearch with Elasticsearch-py using Bulk-API
I'm trying to add a timestamp to my data, have elasticsearch-py bulk index it, and then display the data with kibana.
My data is showing up in kibana, but my timestamp is not being used. When I go to the "Discovery" tab after configuring my index…

CookieEmpire
- 179
- 1
- 9
5
votes
1 answer
Version conflict when using the delete method of elasticsearch-dsl
So, we're using elasticsearch in our Django project, and we're using the elasticsearch-dsl python library.
We got the following error in production:
ConflictError(409,…

Daniel
- 463
- 1
- 6
- 16
5
votes
3 answers
Elasticsearch-dsl sort, find last X entries
I'm trying to find the last 30 entries into my index/doc type
I've tried nothing and I'm all out of ideas!
My current approach I find all the results over the last 5 minutes, then filter through the results and grab out the last 30 entries, but this…

Basil Wallace
- 61
- 1
- 1
- 5
4
votes
3 answers
How can I bulk upload JSON records to AWS OpenSearch index using a python client library?
I have a sufficiently large dataset that I would like to bulk index the JSON objects in AWS OpenSearch.
I cannot see how to achieve this using any of: boto3, awswrangler, opensearch-py, elasticsearch, elasticsearch-py.
Is there a way to do this…

jtlz2
- 7,700
- 9
- 64
- 114
4
votes
1 answer
Python Elasticsearch create index mapping
I am trying to create a ES index with custom mapping with elasticsearch python to increase the size of text in each document:
mapping = {"mapping":{
"properties":{
"Apple":{"type":"text","ignore_above":1000},
…

data_person
- 4,194
- 7
- 40
- 75
4
votes
1 answer
How to index columns created by django-modeltranslation to Elastic, using django-elasticsearch-dsl?
I've translated my Model fields with django-modeltranslation and implemented search using django-elasticsearch-dsl.
Problem:
django-modeltranslation creates translation fields in DB, and not in my Models, and search is working only for fields…

Oleg Barbos
- 178
- 1
- 10