-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Model.listSearchIndexes()
#14450
Comments
const mongoose = require('mongoose');
const { Schema } = mongoose;
//just there
const vectorModelsSupported = [
{
name: 'text_embedding_3_small',
size: 1536,
enabled: true
},
{
name: 'text_embedding_3_small',
size: 1536,
enabled: true
}
]
const EmbeddingSchema = new Schema({
chunkText: { type: String, maxLength: 32764, default: "" },
embedding_text_embedding_3_small: { type: Array, maxLength: 1536 },
embedding_text_embedding_3_large: { type: Array, },
embedding_text_embedding_ada_002: { type: Array, maxLength: 1536 },
chunkLen: Number,
chunkIndex: Number,
upload: {
type: mongoose.Schema.Types.ObjectId,
ref: "upload",
},
chunkUrl: { type: String, maxLength: 1000, }, /*ex: #page=2 for PDF or #id for HTML*/
created: { type: Date, default: Date.now },
usage: { type: Number },
status: { type: String, default: "inactive" }, // inactive, active | error, selected, deleted
});
const Test = mongoose.model('Test', EmbeddingSchema);
async function run() {
await mongoose.connect('mongodb://localhost:27017');
vectorModelsSupported.forEach((model) =>{
if (model.enabled){
//const field =
const fields = {}
fields[`embedding_${model.name}`]= [
{
"dimensions": model.size, // 1536,
"similarity": "euclidean",
"type": "knnVector"
}
]
try{
Test.createSearchIndex({
name: model.name, // "text_embedding_3_small",
definition: {
"mappings": {
"fields": fields
}
}
}
)
}
catch (err){
console.log('err', err);
}
}
})
}
run(); |
With the latest Mongoose, I was able to catch error directly treating as a promise so it didn't send a SIG TERM
I suppose the real issue is that I don't get the list of search indexes when I use
or accessing this property
The list returned is always empty. Question: Thank you |
Please modify my script to demonstrate your issue. Also when using code blocks, use three ` to have it appear as a code block like so: "```" |
The issue in the original post is that you need to In terms of listing existing search indexes, we're currently missing an implementation of |
Model.listSearchIndexes()
Fantastic ! Thank you for adding the Model.listSearchIndex() and respond to this issue. Best wishes |
Prerequisites
Mongoose version
8.2.2
Node.js version
16.20.2
MongoDB server version
Atlas latest
Typescript version (if applicable)
No response
Description
When I use model.createSearchIndex() with an index that already exists, my node application is going down with a SIGTERM
Steps to Reproduce
Use an existing test case to create a search index, but attempt to create it twice with the same name
Expected Behavior
the createSearchIndex should throw an error I can catch, or there should be an API that returns the search index.
The Model.listIndexes does not return the search indexes.
The text was updated successfully, but these errors were encountered: