What do the results of an array inside an object mean? #379
-
I'm working on a React app with NodeJS as backend that requires fulltext search... However I'm gaving some issues...
If I understand this correctly, in my scenario I would need to:
Because the results from .search() return to me only ids. All help is appreciated 👍 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
UPDATING THE QUESTION I have experimented with this and it all works, but I still don't understand what the results I get are... My records look like this; Array<{
id: number;
url: string;
transcript: Array<{
timestamp: string;
transcript: string;
}>;
}> I want to be able to search by const file = fs.readFileSync(searchIndexPath, {
encoding: "utf-8",
flag: "r",
});
const transcriptsJson = (await JSON.parse(file)) as Array<{
id: number;
url: string;
transcript: Array<{
timestamp: string;
transcript: string;
}>;
}>;
const flexIndex = new Document({
tokenize: "full",
document: {
id: "record:id",
index: ["record:url", "record:transcript[]:transcript"],
enrich: true
},
});
transcriptsJson.forEach((_video) => {
flexIndex.add({
record: {
id: _video.id,
url: _video.url,
transcript: [..._video.transcript],
},
});
}); I then search it like so: const x = flexIndex.search("youtube", {
limit: 5,
suggest: true,
index: ["record:url", "record:transcript[]:transcript"],
}); And then the search returns this: What is the interpretation of the result? I know when i get that for example And now I could theoretically search that file and get the object with the results' id? Or is there a way to get the whole object immediately? Because Am I missing something here? Also, to get the exact transcript object which it found I would need to have id's inside the array which is not allowed? |
Beta Was this translation helpful? Give feedback.
-
To answer myself and anyone who may be lost, I forgot to include |
Beta Was this translation helpful? Give feedback.
To answer myself and anyone who may be lost, I forgot to include
enrich: true
when searching so it didn't return any data...