Similarity Search Returning Null Result (Milvus, NodeJS) (PLEASE HELP) #33809
Replies: 6 comments 33 replies
-
Set the consistency_level to be Strong and try again.
Consistency level controls the data visibility for search/query. |
Beta Was this translation helpful? Give feedback.
-
can you try attu to check if your data has been inserted? |
Beta Was this translation helpful? Give feedback.
-
anyway, can you print this
|
Beta Was this translation helpful? Give feedback.
-
Hey, the data is now being added to the collection in milvus, ive set the
dim to 10, but the similarity vector result is still null
…On Fri, 14 Jun 2024 at 02:36, ryjiang ***@***.***> wrote:
what is your milvus version?
—
Reply to this email directly, view it on GitHub
<#33809 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5WALDJILMWZETUI65FE3V3ZHJCI3AVCNFSM6AAAAABJHD353GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TONRZGE4DI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I use the load collection function.
const { MilvusClient , ConsistencyLevelEnum } = require('
@zilliz/milvus2-sdk-node');
const { getCollectionName } = require('../utils/config'); // Import the
config module
const client = new MilvusClient({ address: 'localhost:19530' });
async function similaritySearch(queryEmbedding) {
try {
const collectionName = getCollectionName(); // Retrieve the collection name
if (!collectionName) {
throw new Error('Collection name is not set.');
}
await client.loadCollection({
collection_name: collectionName
});
const searchParams = {
anns_field: "vector",
topk: "3",
metric_type: "L2",
};
// Conduct similarity search
const results = await client.search({
collection_name: collectionName,
vectors: [queryEmbedding],
search_params: searchParams,
vector_type: 101,
});
// Check if response is defined and has results
if (!results || !results.results) {
throw new Error('Search response is undefined or does not contain results');
}
console.log('Similarity search response:', results.results);
return results.results;
} catch (error) {
console.error('Error during similarity search:', error);
throw error;
}
}
module.exports = { similaritySearch };
…On Fri, 14 Jun 2024 at 04:53, ryjiang ***@***.***> wrote:
do you use client.loadCollectionSync ?
—
Reply to this email directly, view it on GitHub
<#33809 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5WALDL2S6Z4NIPYYHEV753ZHJSLPAVCNFSM6AAAAABJHD353GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TONRZHE3DQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi, I know why, it is not something to do with Milvus itself but to do with the local Milvus db of you. I encounter the same problem, I don't know how to solve to be honest for local Milvus, but i used 'zilliz.com' for my milvus database and it is all good. Maybe consider using this cloud solution until somebody found out the reason |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to Implement a RAG using Milvus, Langchain and NodeJS. The Embedding for the Text and Query are being generated but upon performing a similarity search using both of their embeddings, nothings being returned.
PS: The main code for searching is in similaritySearch.js, the code for creating a collection and inserting embedding is in milvus.js, the code for generating the embeddings is in processing.js
milvus.js:
const { MilvusClient, DataType } = require('@zilliz/milvus2-sdk-node');
const express = require('express');
const app = express();
app.use(express.json());
const client = new MilvusClient("localhost:19530");
function generateUniqueCollectionName() {
const timestamp = Date.now();
return
embedding_${timestamp}
;}
async function storeEmbeddings(collectionName, filename, embeddings) {
try {
console.log(
Embedding length: ${embeddings.length}
);}
module.exports = {
storeEmbeddings,
generateUniqueCollectionName,
};
query.js:
const express = require('express');
const { generateEmbedding } = require('../utils/processing');
const { similaritySearch } = require('../utils/similaritySearch.js');
const router = express.Router();
router.post('/', async (req, res) => {
try {
const { query } = req.body;
});
module.exports = router;
similaritySearch.js:
const { MilvusClient } = require('@zilliz/milvus2-sdk-node');
const { getCollectionName } = require('../utils/config'); // Import the config module
const client = new MilvusClient({ address: 'localhost:19530' });
async function similaritySearch(queryEmbedding) {
try {
const collectionName = getCollectionName(); // Retrieve the collection name
if (!collectionName) {
throw new Error('Collection name is not set.');
}
}
module.exports = { similaritySearch };
processing.js:
const fs = require('fs').promises;
const { OpenAI } = require('openai');
const { RecursiveCharacterTextSplitter } = require('langchain/text_splitter');
const openai = new OpenAI({ apiKey: 'sk-proj-o70B1pGGGDU5fg1as1DcT3BlbkFJOiMIcI2ocj15oSJO5gLQ' });
async function processDocument(filePath) {
try {
const text = await fs.readFile(filePath, 'utf-8');
console.log(
Text from file: ${text}
);console.log(
Text length: ${text.length}
);}
async function splitDocumentIntoChunks(text) {
const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 50, chunkOverlap: 10 });
}
async function generateEmbeddingsForChunks(chunks) {
const embeddings = [];
}
async function generateEmbedding(text) {
const response = await openai.embeddings.create({
model: "text-embedding-3-small",
input: [text],
encoding_format: "float",
});
}
module.exports = {
processDocument,
generateEmbedding
};
Beta Was this translation helpful? Give feedback.
All reactions