mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-06-27 02:30:08 +00:00

Closes https://github.com/Unstructured-IO/unstructured/issues/1842
Closes https://github.com/Unstructured-IO/unstructured/issues/2202
Closes https://github.com/Unstructured-IO/unstructured/issues/2203
This PR:
- Adds Elasticsearch destination connector to be able to ingest
documents from any supported source, embed them and write the embeddings
/ documents into Elasticsearch.
- Defines an example unstructured elements schema for users to be able
to setup their unstructured elasticsearch indexes easily.
- Includes parallelized upload and lazy processing for elasticsearch
destination connector.
- Rearranges elasticsearch test helpers to source, destination, and
common folders.
- Adds util functions to be able to batch iterables in a lazy way for
uploads
- Fixes a bug where removing the optional parameter `--fields` broke the
connector due to an integer processing error.
- Fixes a bug where using an [elasticsearch
config](8fa5cbf036/unstructured/ingest/connector/elasticsearch.py (L26-L35)
)
for a destination connector resulted in a serialization issue when
optional parameter `--fields` was not provided.
31 lines
859 B
Python
Executable File
31 lines
859 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
|
|
from elasticsearch import Elasticsearch
|
|
from es_cluster_config import (
|
|
CLUSTER_URL,
|
|
INDEX_NAME,
|
|
PASSWORD,
|
|
USER,
|
|
)
|
|
|
|
N_ELEMENTS = 1404
|
|
|
|
if __name__ == "__main__":
|
|
print(f"Checking contents of index" f"{INDEX_NAME} at {CLUSTER_URL}")
|
|
|
|
print("Connecting to the Elasticsearch cluster.")
|
|
client = Elasticsearch(CLUSTER_URL, basic_auth=(USER, PASSWORD), request_timeout=30)
|
|
print(client.info())
|
|
|
|
count = int(client.cat.count(index=INDEX_NAME, format="json")[0]["count"])
|
|
try:
|
|
assert count == N_ELEMENTS
|
|
except AssertionError:
|
|
sys.exit(
|
|
"Elasticsearch dest check failed:"
|
|
f"got {count} items in index, expected {N_ELEMENTS} items in index."
|
|
)
|
|
print(f"Elasticsearch destination test was successful with {count} items being uploaded.")
|