Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
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
//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: 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 createSearchIndexes = async () => {
//debug("createSearchIndexes", "This is the list of indexes:", await embedding.listIndexes())
debug("createSearchIndexes", "This is the list of indexes:", await embedding.searchIndexes)
if (!modelsSupported) return;
modelsSupported.forEach((model) =>{
if (model.enabled){
//const field =
const fields = {}
fields[`embedding_${model.name}`]= [
{
"dimensions": model.size, // 1536,
"similarity": "euclidean",
"type": "knnVector"
}
]
try{
embedding.createSearchIndex({
name: model.name, // "text_embedding_3_small",
definition: {
"mappings": {
"fields": fields
}
}
}
)
}
catch (err){
debug("createSearchIndexes", "Failed to create index for model ",model, err)
}
}
})
}
embedding.on('index',(event) => {
debug("Embedding", "===> This is an index event", event)
createSearchIndexes()
})
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.