Python's official low-level client for Elasticsearch
Questions tagged [elasticsearch-py]
194 questions
2
votes
1 answer
Use SQL Access in Elasticsearch python client
I am trying to use the python client for elastic search to query an index using SQL access for elastic search. I want to query an index using sql syntax. How do i specify to elasticsearch that it has to read SQLsyntax?
def searchText(text):
t1…

sachin chauhan
- 33
- 1
- 7
2
votes
1 answer
Is it possible, in Elasticsearch, to do a temporary POST to an index?
I would like to know if I can temporarily save a document to an index, and when I want to actually fully publish/POST this document, can I take the "temporary"/"dry-run" flag away from the document?

Justin Reddick
- 441
- 1
- 5
- 20
2
votes
1 answer
Adding new documents to elasticsearch with mapping via elasticsearch.index, body structure
I'm building blog-like app with flask (based on Miguel Grinberg Megatutorial) and I'm trying to setup ES indexing that would support autocomplete feature. I'm struggling with setting up indexing correctly.
I started with (working) simple indexing…

Jakub Królikowski
- 403
- 1
- 7
- 16
2
votes
0 answers
Is it possible to receive a gzipped response via elasticsearch-py?
I have an API (via hug) that sits between a UI and Elasticsearch.
The API uses elasticsearch-py to run searches, for example:
es = Elasticsearch([URL], http_compress=True)
@hug.post('/search')
def search(body):
return es.search(index='index',…

Chris
- 149
- 10
2
votes
1 answer
Using multi_match with Elasticsearch bulk scan in Python
I'm trying to use the multi_match functionality within Elasticsearch using the elasticsearch-py library.
Setting it up like this:
res = helpers.scan(es, index="allcomms", query = {
"multi_match" : {
"query": 'multiple terms',
…

Steven
- 824
- 1
- 8
- 23
2
votes
1 answer
python-elasticsearch: how do you enable curl logging?
I am using python-elasticsearch module, I read in the python-elasticsearch documentation that you can log all the underlying HTTP requests as command line curl commands:
elasticsearch.trace can be used to log requests to the server in the
form of…

Trevor Boyd Smith
- 18,164
- 32
- 127
- 177
2
votes
2 answers
Max value of field using Elasticsearch Python API
I'm trying to get the max value of a field "UID" from Elasticsearch using its Python API. When I try it using the below code I get an error.
res = es.search(index="some_index", body={"query": {"size": 0,
"aggregations": {
"maxuid": {
"max": {
…

Reddy
- 31
- 5
2
votes
1 answer
Using HstoreField in Django/ElasticSearch
I'm new to elastic search and I really want to implement it in my Django project.
My problem: I want to store a Python dict object
({'key_1': 'value_1', 'key_2': 'value_2', [...]})
and be sure that my search will look each key.
In Django I…

MrDiben
- 60
- 6
2
votes
1 answer
Instantiating an Elasticsearch client fails only when using python3
I've been trying to use python's elasticsearch library to connect to my ElasticSearch host machine.
So the code looks like:
client = Elasticsearch(
["https://my-machine.io:9200"],
http_auth=("user", "password")
)
Now the problem…

Adriano Todaro
- 321
- 1
- 4
- 14
2
votes
3 answers
elasticsearch-py search using source filter
I am using elasticsearch-py (es version is 2.3) and would like to return just the 'title' field from all documents in an index with the mapping: actors, director, genre, plot, title, year.
I'm currently trying messages = es.search(index="movies",…

nmacc
- 57
- 2
- 6
2
votes
1 answer
escape special character in elasticsearch query
My question is simple, I can't use @ in the search query. Finally, I found that I can escape the special characters using the backslash.
GET index/_search
{
"size": 20,
"query": {
"query_string": {
"query": "\@as",
"analyzer":…

Tamizharasan
- 293
- 1
- 5
- 18
2
votes
0 answers
How to get frequency of all terms in an elasticsearch index
I have a corpus of documents indexed . I also stored the term vectors when indexing. Now I want to retrieve term vectors of all documents satisfying some filtering options.
I was able to get term vector for a single document or for a set of…

user3760679
- 41
- 3
2
votes
1 answer
How do I properly construct a query using the elasticsearch python API?
I've got some code that looks like this
from elasticsearch import Elasticsearch
client = Elasticsearch(hosts = [myhost])
try:
results = es_client.search(
body = {
'query' : {
'bool' : {
…

Zack
- 13,454
- 24
- 75
- 113
2
votes
2 answers
how to get total tokens count in documents in elasticsearch
I am trying to get the total number of tokens in documents that match a query. I haven't defined any custom mapping and the field for which I want to get the token count is of type 'string'.
I tried the following query, but it gives a very large…

user3760679
- 41
- 3
2
votes
2 answers
Delete documents from ElasticSearch index in python
Using elasticsearch-py, I would like to remove all documents from a specific index, without removing the index. Given that delete_by_query was moved to a separate plugin, I want to know what is the best way to go about this?

zanderle
- 815
- 5
- 15