function to create vector embeddings : -
async getVectorEmbedding(text) {
try {
const response = await this.client.ingest.simulate({
body: {
pipeline: {
id: process.env.INGEST_PIPELINE,
},
docs: [
{
_source: {
combined_text: text,
},
},
],
},
})
if (response.body.docs[0].error) {
console.error('Error in processing document:', response.body.docs[0].error)
return []
}
return response.body.docs[0]._source.vector_embedding
} catch (err) {
console.error('Failed to get vector embedding', err.meta.body)
return []
}
}
ingest pipeline :-
{
"nlp-ingest-pipeline": {
"description": "A text embedding pipeline",
"processors": [
{
"text_embedding": {
"model_id": "model_id",
"field_map": {
"combined_text": "vector_embedding"
}
}
}
]
}
}
Getting this error :-
{
error: {
root_cause: [ [Object] ],
type: 'parse_exception',
reason: '[processors] required property is missing',
property_name: 'processors'
},
status: 400
}