Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode
Light Logo Semantic AI
Dark Logo Semantic AI
Light Logo

Semantic AI

Dark Logo

Semantic AI

Documentation

  • Introduction
  • Installation
  • Connectors
    • Microsoft SharePoint
    • MYSQL
    • SQLITE
  • DF Extraction
  • Embeddings
    • Hugging Face 🤗
    • Open AI
  • Vector Database
    • Elastic Search
    • Qdrant
    • OpenSearch
  • Indexer
  • LLM Models
    • IBM Watsonx LLM
    • LLAMA 2
    • OpenAI
  • NLP to Text
    • Natural Language Processing
  • Semantic Search
Back to top
Join

Elastic Search¶

https://github.com/decisionfacts/semantic-ai/blob/master/docs/source/_static/images/logo/elastic-logo-920x920-sue-v02.png?raw=true:alt:Logo

Elasticsearch is the distributed search and analytics engine. Elasticsearch provides real-time search and analytics for all types of data. Whether structured or unstructured text, numerical data.

Setup Elasticsearch:

Running a elasticsearch using docker.

docker run -p 9200:9200 -e "discovery.type=single-node" -e "xpack.security.enabled=false" -e "xpack.security.http.ssl.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:8.9.0

Once the elasticsearch instance is running, you can connect to it using the Elasticsearch URL and index name along with the embedding object to the constructor.

To Elasticsearch object creation

from semantic_ai.indexer import ElasticsearchIndexer
from semantic_ai.embeddings.huggingface import HFEmbeddings

embeddings = await HFEmbeddings().embed()
elastic_search = await ElasticsearchIndexer(
        url="http://localhost:9200",
        index_name="test_index",
        embedding=embeddings
).create()

Authentication:

For production, we recommend to enable the security. To connect with login credentials. We can us the parameters api_key or es_user and password

elastic_search = await ElasticsearchIndexer(
        url="http://localhost:9200",
        index_name="test_index",
        embedding=embeddings,
        es_user="elastic",
        es_password="password"
).create()

Index:

Before index, we need to extract the content from the documents and constructed as json format. Here we can use the DF Extraction. Once we extracted the data using df-extraction and converted as json format we can start to index.

await elastic_search.index("/home/test/sample.json")

If we lots of files, stored into directory and we can use directory path in index

await elastic_search.index("/home/test/")

You can check your elasticsearch vector database its indexing or not.

Search Query:

query = "<your query>"
result = await elastic_search.asimilarity_search(query)
Next
Qdrant
Previous
Vector Database
Copyright © 2024, DecisionFacts
Made with Sphinx and @pradyunsg's Furo