elasticsearch 芭蕾舞积分器与弹性搜索,elasticsearch,indexing,ballerina,elasticsearch,Indexing,Ballerina" /> elasticsearch 芭蕾舞积分器与弹性搜索,elasticsearch,indexing,ballerina,elasticsearch,Indexing,Ballerina" />

elasticsearch 芭蕾舞积分器与弹性搜索

elasticsearch 芭蕾舞积分器与弹性搜索,elasticsearch,indexing,ballerina,elasticsearch,Indexing,Ballerina,我正在进行我的学士学位项目,我必须使用Ballerina integrator中间件 现在我需要做一个服务,它能够将来自ballerina的数据索引到Elasticsearch中。有没有一种方法可以只使用ballerina(不使用日志存储或文件节拍…)与Elasticsearch通信,就像我们与SQL数据库通信一样 如果有人在找同样的东西,我刚刚找到了一种与Elastic沟通的方法,它工作得很好 ---这是密码--- 导入ballerina/http; 输入芭蕾舞演员/原木; 侦听器http:l

我正在进行我的学士学位项目,我必须使用Ballerina integrator中间件

现在我需要做一个服务,它能够将来自ballerina的数据索引到Elasticsearch中。有没有一种方法可以只使用ballerina(不使用日志存储或文件节拍…)与Elasticsearch通信,就像我们与SQL数据库通信一样


如果有人在找同样的东西,我刚刚找到了一种与Elastic沟通的方法,它工作得很好

---这是密码---

导入ballerina/http;
输入芭蕾舞演员/原木;
侦听器http:listener-httpListener=new(9090);
http:Client-elasticDB=new(“http://localhost:9200/");
@http:ServiceConfig{
基本路径:“/elastic”
}
httpListener上的服务GetElasticSource{
@http:ResourceConfig{
方法:[“获取”],
路径:“/{index}/_source/{id}”
}
资源函数retrieveElasticIndexById(http:Caller-httpCaller,http:Request-httpRequest,string-index,string-id){
http:Response resp=new;
var data=elasticDB->get((“/”+index+“/_source/”+id));
if(数据是http:Response){
resp=数据;
}
var respRet=httpCaller->resp(resp);
if(respRet为错误){
日志:printError(“响应客户端时出错”,err=respRet);
}
}
}
import ballerina/http;
import ballerina/log;


listener http:Listener httpListener = new(9090);

http:Client elasticDB = new("http://localhost:9200/");

@http:ServiceConfig{
    basePath: "/elastic"
}

service GetElasticSource on httpListener{
    @http:ResourceConfig {
        methods: ["GET"],
        path: "/{index}/_source/{id}"
    }

    resource function retrieveElasticIndexById(http:Caller httpCaller,   http:Request httpRequest, string index, string id){
        http:Response resp = new;

        var data = elasticDB->get(<@untained> ("/"+index+"/_source/"+id));

        if(data is http:Response){
            resp = data;
            }

        var respRet = httpCaller->respond(resp);
        if(respRet is error){
            log:printError("error responding to the client", err = respRet);
        }
    }
}