"Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.",
friendlyName:"ElasticSearch",
datasource:{
url:{
type:DatasourceFieldTypes.STRING,
required: true,
default:"http://localhost:9200",
},
},
query:{
create:{
type:QueryTypes.FIELDS,
customisable: true,
fields:{
index:{
type:DatasourceFieldTypes.STRING,
required: true,
},
},
},
read:{
type:QueryTypes.FIELDS,
customisable: true,
fields:{
index:{
type:DatasourceFieldTypes.STRING,
required: true,
},
},
},
update:{
type:QueryTypes.FIELDS,
customisable: true,
fields:{
id:{
type:DatasourceFieldTypes.STRING,
required: true,
},
index:{
type:DatasourceFieldTypes.STRING,
required: true,
},
},
},
delete:{
type:QueryTypes.FIELDS,
fields:{
index:{
type:DatasourceFieldTypes.STRING,
required: true,
},
id:{
type:DatasourceFieldTypes.STRING,
required: true,
},
},
},
},
}
classElasticSearchIntegration{
privateconfig: ElasticsearchConfig
privateclient: any
constructor(config: ElasticsearchConfig){
this.config=config
this.client=newClient({node: config.url})
}
asynccreate(query:{index: string;json: object}){
const{index,json}=query
try{
constresult=awaitthis.client.index({
index,
body: json,
})
returnresult.body
}catch(err){
console.error("Error writing to elasticsearch",err)