Python's official low-level client for Elasticsearch
Questions tagged [elasticsearch-py]
174 questions
2
votes
1 answer
elasticsearch python client - work with many nodes - how to work with sniffer
i have one cluster with 2 nodes.
i am trying to understand the best practise to connect the nodes, and check failover when there is downtime on one node.
from documentation:
es = Elasticsearch(
['esnode1', 'esnode2'],
# sniff before doing…
Eyal Ch
- 7,642
- 3
- 37
- 47
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
- 31
- 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
- 11,342
- 19
- 69
- 105
2
votes
2 answers
How to insert new or update old document using elasticsearch-py?
What is the most elegant way to insert a new document (if not already exists) or update (increase counter by 1) of an already existed document?
This one:
res = elasticsearch.update(
index='stories-test',
doc_type='news',
…
user706838
- 4,494
- 10
- 47
- 73
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
- 775
- 4
- 15
2
votes
0 answers
elasticsearch-py driver is not filtering data properly when aggregating
I faced a weird with elasticsearch python drivers and would like if someone can explain it to me! The below code works directly from cURL but doesn't work with python-requests or elasticsearch-py, strangely, it works when I switch to pyelasticsearch…
mjalajel
- 2,101
- 20
- 26
1
vote
2 answers
how can I get the searched string from list in my es.search result?
The situation is I load the df into es, the df has two columns:'url' & 'text'.
And I query the 'text' with values in a list which named 'forbidden_words'.
I wanna make the res can also present two columns, one is "url", one is "forbidden_words"…
zoe
- 11
- 2
1
vote
1 answer
Elasticsearch Parent-Child Mapping and Indexing
I was following the book "Elasticsearch: The Definitive Guide". This book is outdated and when something was not working I was searching it on the internet and making it work with newer versions. But I can't find anything useful for Parent-Child…
Sharmiko
- 295
- 14
1
vote
1 answer
aggregation (many value in one field) elasticsearch
I have many values in one field, when I do an aggregations, I receive these values as separate values.
Exemple :
name : jess , Region : new york
name : jess , Region : poland
request :
query = {
"size": total,
"aggs": {
…
Enya Ece Arzu
- 13
- 5
1
vote
1 answer
Convert Kibana query (create index pattern) to Python request
I'm trying to convert this Kibana query to Python:
PUT /.kibana/_doc/index-pattern:tempindex
{
"type": "index-pattern",
"index-pattern": {
"title": "tempindex",
"timeFieldName": "sendTime"
}
}
This is what I have so far:
HEADERS = {
…
ArdaS
- 21
- 7
1
vote
1 answer
Index special JSON file in elasticsearch-py?
I am following this answer Index JSON files in elasticsearch using Python? however my JSON file is still recognized as one single document only.
ElasticSearch creates single fields for every entry as '0.created_at' as seen in Kibana.
My JSON file…
Raphael B.
- 35
- 3
1
vote
1 answer
Trying to load json docs in elasticsearch
I am trying to follow this answer, but I am getting error in the actions parameter of bulk method.
I am able to use next to generate array of json objects but when I pass it to helpers.bulk I get error.
This is my code:
from elasticsearch import…
Murtaza Haji
- 664
- 1
- 7
- 26
1
vote
1 answer
extending an list field in elasticsearch document
I have user_data field in my elasticsearch index document for eg;
sample doc:
user_data : [
{
userid :1,
order_id :32
},
{
userid :8,
order_id…
DARK_C0D3R
- 1,209
- 9
- 19
1
vote
2 answers
ElasticSearch not sorting results
I'm trying to sort the results based on a numeric field,
Here is my mapping:
{
"elasticie": {
"mappings": {
"properties": {
"name": {
"type": "text",
"fields": {
"keyword": {
"type":…
DarkSuniuM
- 2,099
- 1
- 19
- 34
1
vote
1 answer
ES dense_vector field: 'dims' must be specified
I have an ElasticSearch (v7.5.1) index with a dense_vector field called lda, with 150 dimensions. The mapping, as shown on http://localhost:9200/documents/_mapping, looks like this:
"documents": {
"mappings": {
[...]
"lda": {
…
Carsten
- 1,406
- 19
- 44