[Python] how to use elasticsearch with langchain

Discussão em 'Python' iniciado por Stack, Março 6, 2025.

  1. Stack

    Stack Membro Participativo

    I want to use elasticsearch with the langchain, i have gone thru the documentation but in the documentation they create a text file which is appended in elasticsearch and than you can query it. basically i want to perform RAG. I need to query the data already existing in the elasticsearch at some index

    from elasticsearch import Elasticsearch
    # Connect to Elasticsearch cluster
    es = Elasticsearch(['http://10.100.102.107:9200'])
    # Define your query
    query = {
    "query": {
    "match_all": {} # Match all documents
    }
    }
    # Execute the query
    result = es.search(index="instagram_index", body=query)
    # Process the results
    for hit in result['hits']['hits']:
    print(hit['_source'])


    this is the code where it returns dummy data of some accounts, consisting of username, text etc

    i want to query this data through lanngchain i am relatively new to this field and i know there is a lot to learn but i need guidance regarding this.

    Continue reading...

Compartilhe esta Página