Questions tagged [pyelasticsearch]

pyelasticsearch is a clean, future-proof, high-scale python API to elasticsearch.

pyelasticsearch is a clean, future-proof, high-scale python API to elasticsearch. It provides features like...

  • Transparent conversion of Python data types to and from JSON
  • Translating HTTP status codes representing failure into exceptions
  • Connection pooling Load balancing of requests across nodes in a cluster Failed-node marking to avoid downed nodes for a period
  • Optional automatic retrying of failed requests

https://pyelasticsearch.readthedocs.io/en/latest/

84 questions
39
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
10
votes
1 answer

How to disconnect from elasticsearch-py client/connection-pool

Whats the correct way to disconnect an elasticsearch-py (python) client rsp. close an existing connection pool? I cannot find any information in the docs.
user2694588
  • 153
  • 1
  • 7
8
votes
1 answer

No handlers could be found for logger "elasticsearch.trace"

Updated: Turns out, this is not a function of cron. I get the same behavior when running the script from the command line, if it in fact has a record to process and communicates with ElasticSearch. I have a cron job that runs a python script which…
Laizer
  • 5,204
  • 5
  • 40
  • 69
6
votes
4 answers

ElasticSearch query_string fails to parse query with some characters

I'm using the ElasticSearch (2.4) and the official Python client to perform simple queries. My code: from elasticsearch import Elasticsearch es_client = Elasticsearch("localhost:9200") index = "indexName" doc_type = "docType" def search(query,…
iamdeit
  • 3,855
  • 3
  • 20
  • 37
6
votes
4 answers

elasticsearch scrolling using python client

When scrolling in elasticsearch it is important to provide at each scroll the latest scroll_id: The initial search request and each subsequent scroll request returns a new scroll_id — only the most recent scroll_id should be used. The following…
Dror
  • 9,918
  • 17
  • 70
  • 137
6
votes
1 answer

Format the output of elasticsearch-py

I'm trying to use the python client for elasticsearch. Here is a minimal example: import logging logging.basicConfig() from elasticsearch import Elasticsearch as ES print "Setup connection..." es=ES(['localhost:8080']) print "Done!" print "Count…
Dror
  • 9,918
  • 17
  • 70
  • 137
5
votes
0 answers

pyelasticsearch bulk ValueError: too many values to unpack (expected 2)

I'm new in Python and Elasticsearch. I'm trying to write code to insert documents in Elassticsearch using bulk. It is based on this description: http://pyelasticsearch.readthedocs.io/en/latest/api/#pyelasticsearch.ElasticSearch.bulk My code: >>>…
fikfok
  • 51
  • 2
5
votes
1 answer

elasticsearch dynamic query - Add another field to each document returned

What I need is very simple, but I am unable to find how to do it in Elasticsearch, possibly because of the complexity of what is required to be done. Input (two sample JSON documents) { "car" : 150, "bike" : 300 } { "car" : 100, "bike" : 200} What…
5
votes
2 answers

elasticsearch python bulk api (elasticsearch-py)

I'm confused about py-elasticsearch bulk @Diolor solution works https://stackoverflow.com/questions/20288770/how-to-use-bulk-api-to-store-the-keywords-in-es-by-using-python, but I would like to use plain es.bulk() My code: from elasticsearch import…
4
votes
3 answers

Elasticsearch Aggregation by Day of Week and Hour of Day

I have documents of type: [{"msg":"hello", date: "some-date"},{"msg":"hi!", date: "some-date"}, ... I want to have the count of documents by day of week. For example x messages were sent on Monday and y were sent on Tuesday and so on. I have used…
4
votes
1 answer

Specify search type in pyelasticsearch

Is there a way to specify the search type when using pyelasticsearch? There's nothing in the documentation for 'scan', 'scroll', 'query_and_fetch', etc. Running the following code: from pyelasticsearch import ElasticSearch es =…
Cam S
  • 105
  • 4
4
votes
4 answers

Elasticsearch python API: Delete documents by query

I see that the following API will do delete by query in Elasticsearch - http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-delete-by-query.html But I want to do the same with the elastic search bulk API, even though I could…
sysuser
  • 954
  • 1
  • 11
  • 27
3
votes
1 answer

Create custom analyzer filter for a index in py-elasticsearch-dsl

i'm working with py-elasticsearch-dsl for my master, i'm creating a index of title documents in a corpus of turkish titles, and i need implements a custom lowercase analyzer for turkish language:…
SalahAdDin
  • 1,432
  • 14
  • 42
3
votes
4 answers

How to delete documents from multiple indices using particular field name in elasticsearch python?

This is sample document. { "_index": "mqtt-index-2018.01.23", "_type": "iot_data", "_id": "AWEjA7LNRU4cTUO-Lyj4", "_score": null, "_source": { "message": "{\"datastream_name\": \"roshni\", \"value\": 12, \"context\": {\"latitude\": 0,…
3
votes
1 answer

highlighting based on term or bool query match in elasticsearch

I have two queries. {'bool': {'must': { 'terms': 'metadata.loc':['ten','twenty']} { 'terms': 'metadata.doc':['prince','queen']} } {'should': { 'match': 'text':'kingdom of dreams'} …
Prannoy Mittal
  • 1,285
  • 3
  • 19
  • 29
1
2 3 4 5 6