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/

89 questions
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
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
  • 163
  • 1
  • 8
8
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
  • 5,485
  • 4
  • 26
  • 40
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,932
  • 7
  • 46
  • 73
7
votes
5 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
  • 12,174
  • 21
  • 90
  • 160
6
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…
6
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…
6
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…
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
  • 12,174
  • 21
  • 90
  • 160
5
votes
2 answers

Elastic search not giving data with big number for page size

Size of data to get: 20,000 approx Issue: searching Elastic Search indexed data using below command in python but not getting any results back. from pyelasticsearch import ElasticSearch es_repo = ElasticSearch(settings.ES_INDEX_URL) search_results =…
Kishan Mehta
  • 2,598
  • 5
  • 39
  • 61
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
2 answers

elasticsearch-py and multiprocessing

What is the correct way to use elasticsearch-py in multiprocessing script? Should I create a new client object before start processes and use that object or should I create a new object inside each of the processes. The 2nd one gives me an an error…
kiran
  • 477
  • 1
  • 7
  • 11
4
votes
1 answer

How to have Range and Match query in one elastic search query using python?

I have to find the matching documents which have the string, for example: "sky", within some "key" range. When I write separate match and range query, I get the output from the ES but it throws an exception when merged together. range query: res =…
Amogh Mishra
  • 1,088
  • 1
  • 16
  • 25
4
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,525
  • 5
  • 21
  • 32
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
  • 115
  • 1
  • 4
1
2 3 4 5 6