小编Mik*_*114的帖子

ElasticSearch给出ReceiveTimeoutTransportException

嗨,我正在尝试将我的ElasticSearch客户端连接到我的localhost并尝试从那里获取索引.

import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;
import org.elasticsearch.client.transport.*;
import org.elasticsearch.common.transport.*;
import java.io.IOException;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
public class ESClient
{
    public static void search()throws IOException
    {
        Node node;
        node = nodeBuilder().clusterName("elasticsearch").node();
        Client client;
        client= new TransportClient()
                .addTransportAddress(new InetSocketTransportAddress("localhost", 9200));
        GetResponse response;
        response= client.prepareGet("twitter", "tweet", "1").execute() .actionGet();
        System.out.println(response.toString());

    }
    public static void main(String args[])throws IOException
    {
        search();

    }

}
Run Code Online (Sandbox Code Playgroud)

我使用终端创建了索引.

curl -XPUT'http :// localhost:9200/twitter / 'curl -XPUT'http :// localhost:9200/twitter/_mapping/tweet'- d'{
"tweet":{"properties":{
"message" :{"type":"string","store":true}}
}}'

当我执行它时,抛出以下错误,

NFO:[Blackheath]无法获取[#transport#-1] [BLRMCB-C02L56J4DR53.local] [inet [localhost/127.0.0.1:9200]]的节点信息,断开连接... org.elasticsearch.transport.ReceiveTimeoutTransportException: [] …

java curl elasticsearch

5
推荐指数
1
解决办法
3238
查看次数

在 C++ 中的排序向量中搜索范围 [x,y] [使用 lower_bound() 和 upper_bound() ]

我有一个排序向量数组,

向量<整数> b[1000009];

现在我必须在行 b[factor] 中搜索 x 和 y 之间的范围。
'factor'、'x' 和 'y' 都是整数。
我使用了以下方法:

        int lb,ub;
        if(b[factor][0]>=x){lb=0;}
        else
            {
                lb=upper_bound(b[factor].begin(),b[factor].end(),x)-b[factor].begin();
                while(b[factor][lb-1]>=x)lb--;
            }
        if(b[factor][sz2-1]<=y)
            {
                ub=sz2-1;
            }
        else {
                ub=lower_bound(b[factor].begin(),b[factor].end(),y)-b[factor].begin();
                while(b[factor][ub]>y)ub--;
            }
Run Code Online (Sandbox Code Playgroud)

但是这种方法并不能一直给出正确的答案。此外,我想使用一些比较器功能来实现相同的功能。这是我第一次使用lower_bound()和upper_bound()。所以请告诉我如何在这里实现比较器功能。

c++ stl lower-bound

4
推荐指数
1
解决办法
1787
查看次数

标签 统计

c++ ×1

curl ×1

elasticsearch ×1

java ×1

lower-bound ×1

stl ×1