A pipeline to transfer documents from Elasticsearch to Pinecone with threading support
Project description
ES to Pinecone Transfer Pipeline
A Python package for transferring documents from Elasticsearch to Pinecone with threading support for faster operations.
Features
- Transfer documents from Elasticsearch to Pinecone with minimal configuration
- Support for multiple embedding providers (OpenAI, HuggingFace)
- Multi-threaded processing for faster operations
- Configurable batch sizes and field selection
- Progress tracking with tqdm
- Comprehensive error handling
Installation
pip install es-to-pinecone-transfer
Quick Start
-
Create a
.envfile with your configuration (see.env.examplefor reference) -
Use the pipeline directly in your code:
from es_to_pinecone_transfer.pipeline import ElasticsearchToPineconePipeline
# Initialize and run the pipeline
pipeline = ElasticsearchToPineconePipeline()
pipeline.run()
- Or use the command-line interface:
es-to-pinecone
Configuration
The pipeline can be configured using environment variables. Here are the key settings:
Elasticsearch Configuration
ES_HOST: Elasticsearch host URLES_USERNAME: Elasticsearch username (optional)ES_PASSWORD: Elasticsearch password (optional)ES_API_KEY: Elasticsearch API key (optional, preferred over username/password)ES_INDEX: Source index name
Embedding Configuration
EMBEDDING_TYPE: Type of embedding to use (openai/huggingface/custom)OPENAI_API_KEY: OpenAI API key (if using OpenAI embeddings)OPENAI_MODEL: OpenAI model to use for embeddingsHUGGINGFACE_MODEL: HuggingFace model to use (if using HuggingFace)
Pinecone Configuration
PINECONE_API_KEY: Pinecone API keyPINECONE_ENVIRONMENT: Pinecone environmentPINECONE_INDEX_NAME: Target Pinecone index name
Pipeline Configuration
BATCH_SIZE: Number of documents to process in each batchMAX_THREADS: Maximum number of threads to useFIELDS_TO_EMBED: Comma-separated list of fields to embed from ES documentsMETADATA_FIELDS: Comma-separated list of fields to include as metadataDEFAULT_NAMESPACE: Pinecone namespace to use
Advanced Usage
Custom Field Mapping
from es_to_pinecone_transfer.pipeline import ElasticsearchToPineconePipeline
pipeline = ElasticsearchToPineconePipeline()
pipeline.set_field_mapping({
'title': 'headline',
'content': 'body',
'author': 'writer',
'timestamp': 'date'
})
pipeline.run()
Progress Callbacks
def on_batch_complete(batch_number, total_batches):
print(f"Completed batch {batch_number} of {total_batches}")
pipeline = ElasticsearchToPineconePipeline()
pipeline.set_progress_callback(on_batch_complete)
pipeline.run()
Error Handling
The pipeline provides comprehensive error handling:
try:
pipeline = ElasticsearchToPineconePipeline()
pipeline.run()
except ElasticsearchConnectionError as e:
print(f"Elasticsearch connection failed: {e}")
except PineconeConnectionError as e:
print(f"Pinecone connection failed: {e}")
except EmbeddingError as e:
print(f"Embedding generation failed: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file es_to_pinecone_transfer-0.1.0.tar.gz.
File metadata
- Download URL: es_to_pinecone_transfer-0.1.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e26f32c15bb40dfbccb5d1e961691a44784171f696ce66b11ffea972f0314454
|
|
| MD5 |
051acfc88383f3edd29ed07abe5ef042
|
|
| BLAKE2b-256 |
dde66d95fd3272352655a42098080ee5c628fa44296ca3d3ade447993e74e17f
|
File details
Details for the file es_to_pinecone_transfer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: es_to_pinecone_transfer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de712f33095ab398101416c89b069d836f2b01ef8122cb536f15668877583b19
|
|
| MD5 |
bbe0cd86ad236183e584a652f698f45f
|
|
| BLAKE2b-256 |
73f27f3cec20ffa79e53ea53f1364f2bf98ec8e9e43981e7a0c3c8a762273697
|