Using Elasticsearch, is it possible to query for documents which are not converted into embeddings? #4924
Replies: 2 comments
-
Hey @ajaykrupalk! Great to see you diving into another interesting challenge with LangChain. How's it going? To query for documents in Elasticsearch that have not been converted into embeddings when using the LangChain JS framework, you would typically follow these steps:
Given the context does not provide details on how documents are stored in Elasticsearch or if there's a mechanism in place to track their conversion status, a generic Elasticsearch query example to find unconverted documents might look like this: const { Client } = require('@elastic/elasticsearch');
const client = new Client({ node: 'http://localhost:9200' });
async function findUnconvertedDocuments() {
const { body } = await client.search({
index: 'your_index_name',
body: {
query: {
bool: {
must_not: [
{
exists: {
field: "converted_to_embeddings"
}
}
]
}
}
}
});
console.log(body.hits.hits);
}
findUnconvertedDocuments(); In this example, Remember, the actual implementation details would depend on how you're managing your documents in Elasticsearch and the mechanism you choose to track whether a document has been converted into embeddings. As for how LangChain JS handles the conversion of documents into embeddings, it does so through the Lastly, LangChain JS interacts with Elasticsearch through the I hope this helps! If you have any more questions, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
@dosu-bot When I set ElasticVectorSearch as my Vector Store, it is only retrieving documents that have been converted to embeddings, while 98% of my data is just some sort of structured or unstructured data that is not converted to embeddings. I would like to retrieve those documents as well and perform some operations const vectorstore = new ElasticVectorSearch(embeddings,clientArgs);
//retrieve the document from the vectorstore
const retriever = vectorstore.asRetriever(); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I am trying to use Elasticsearch with Langchain and I would like to know how I could get documents which are not converted to embeddings. Only a few of my data is converted into embeddings but most of it doesn't. How do I take this forward?
System Info
NA
Beta Was this translation helpful? Give feedback.
All reactions