elasticsearch

Return null if the field doesn't exist

Return null if the field doesn't exist Question: I’m trying to get all the data I need from elasticsearch API using python. However, the data in each objects are different. WHat I mean is: for instance: hits: [ "_source": { "info": { "id": 1234, "name": "xyz apt" "address": "adsfv" }}, "_source": { "info": { "id": …

Total answers: 1

Elasticsearch Search Query using python subprocess: Illegal Argument Exception

Elasticsearch Search Query using python subprocess: Illegal Argument Exception Question: I am trying to run a curl command using the run command in the subprocess module in python. But it is failing. However, the curl command for my elasticsearch search query API is working fine- curl -k XGET -H "Content-Type: application/json" -H "Authorization: ApiKey Q2txZ2FvSUJ6Nlcwa3pjbnh0NUM6enBidjdNLTdRQVNhc0tuTEk5UEZmZw==" …

Total answers: 1

Distinct value in elastic search with extra field inside {"key": "xyz", "doc_count": 1}

Distinct value in elastic search with extra field inside {"key": "xyz", "doc_count": 1} Question: I am working on Elastic Search (version 7.16) with Oython (version 3.6) I have the below rows in Elastic Search: {"owner": "john", "database": "postgres", "table": "sales_tab"}, {"owner": "hannah", "database": "mongodb", "table": "dept_tab"}, {"owner": "peter", "database": "mysql", "table": "new_tab"}, {"owner": "jim", "database": …

Total answers: 1

Providing multiple dense vectors to Elasticsearch script params

Providing multiple dense vectors to Elasticsearch script params Question: I’m using the kNN functionality in Elastic to retrieve the nearest neighbors given a certain vector. However, in contrast with searches based on terms in the query body, I can’t figure out how to do a single search request using multiple vectors. Using the Python elasticsearch …

Total answers: 1

How change the syntax in Elasticsearch 8 where 'body' parameter is deprecated?

How change the syntax in Elasticsearch 8 where 'body' parameter is deprecated? Question: After updating Python package elasticsearch from 7.6.0 to 8.1.0, I started to receive an error at this line of code: count = es.count(index=my_index, body={‘query’: query[‘query’]} )["count"] receive following error message: DeprecationWarning: The ‘body’ parameter is deprecated and will be removed in a …

Total answers: 2

TransportError (429) 'Data too large' when loading JSON docs to ElasticSearch

TransportError (429) 'Data too large' when loading JSON docs to ElasticSearch Question: I have a process running in Python 3.7 that loads JSON files, gathers file rows into chunks in async queues, and incrementally posts chunks to ElasticSearch for indexing. Chunking is meant to avoid overloading the ElasticSearch connection. def load_files_to_queue(file_queue, incomplete_files, doc_queue, index): logger.info("Initializing …

Total answers: 2

Elasticsearch Bulk insert w/ Python – socket timeout error

Elasticsearch Bulk insert w/ Python – socket timeout error Question: ElasticSearch 7.10.2 Python 3.8.5 elasticsearch-py 7.12.1 I’m trying to do a bulk insert of 100,000 records to ElasticSearch using elasticsearch-py bulk helper. Here is the Python code: import sys import datetime import json import os import logging from elasticsearch import Elasticsearch from elasticsearch.helpers import streaming_bulk …

Total answers: 1

Connecting to remote Elasticsearch server with python's Elasticsearch package

Connecting to remote Elasticsearch server with python's Elasticsearch package Question: I want to use a remote Elasticsearch server for my website. I have used elastic.co/ cloud service to create a remote Elasticsearch server. I can connect/ping remote Elasticsearch server using the following command (it is scrubbed of sensitive info): curl -u username:password https://55555555555bb0c30d1cba4e9e6.us-central1.gcp.cloud.es.io:9243 After tying …

Total answers: 2

elasticsearch `No connection could be made because the target machine actively refused it` after using password auth

elasticsearch `No connection could be made because the target machine actively refused it` after using password auth Question: I am trying to connect to my elasticsearch instance using the python elasticsearch library: es = Elasticsearch(HOST="https://elastic:[email protected]",PORT=9243) es = Elasticsearch() but I keep getting the error : elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x000002BD624E6208>: Failed to establish a new …

Total answers: 1

How to handle Transport error in elastic search python client?

How to handle Transport error in elastic search python client? Question: I am uploading pandas dataframe to elastic (using elasticsearch==6.3.1), if the dataframe size is less 100MB it works fine, i am using a solution from How to export pandas data to elasticsearch? def rec_to_actions(df): for record in df.to_dict(orient="records"): yield (‘{ "index" : { "_index" …

Total answers: 2