1

if I do not set size, I can get 10 hits:

SearchResponse sr = client.prepareSearch("xxx").setTypes("xxx")
                .setQuery(rangeQueryBuilder)
                .setQuery(queryBuilder)

but when I set size more than 12:

SearchResponse sr = client.prepareSearch("xxx").setTypes("xxx")
                .setSize(13)
                .setQuery(rangeQueryBuilder)
                .setQuery(queryBuilder)

I get this problem: NoNodeAvailableException[None of the configured nodes were available: [{gw_172.28.236.85:40001}{oHcfPhqFQDSW4opwUuzCpA}{P1GbtDqrRda4nlbRRBmW1Q}{172.28.236.85}{172.28.236.85:40101}{xpack.installed=true}, my java connect code:

    public static TransportClient client() throws UnknownHostException {
    if (client != null) {
        return client;
    }
    synchronized (esConnection_old.class) {
        if (client == null) {
            Settings settings = Settings.builder().put("cluster.name", ClusterName)
                    .put("client.transport.sniff", false)
                    .put(SecurityKey, basicAuthHeaderValue(SecurityUser, SecurityPassword))
                    .build();

            client = new PreBuiltTransportClient(settings);


            String[] oneInstance = GatewayIpPorts.split(",");
            for (String item : oneInstance) {
                String[] ipPort = item.split(":");
                client.addTransportAddresses(new TransportAddress(InetAddress.getByName(ipPort[0]), Integer.parseInt(ipPort[1])));
            }
            return client;
        }
        return client;
    }
}

1 Answers1

0

Normally this exception comes when Elasticsearch needs to perform a certain action on a node (allocation of the shard, indexing, and searching data) and it does not find the nodes which can serve these requests.

You can have a look at NoNodeAvailableException Code and trace back to it, I looked this is the latest code and couldn't find None of the configured nodes were available: for search action which you are trying to perform.

Please provide your elasticsearch version and also confirm this exception comes just because of size param value more than 10?

Amit
  • 30,756
  • 6
  • 57
  • 88
  • Thanks for your answer. My es version is 6.3.2, and I have used java scroll api to get more data, sometimes I can get more than 10, but occurred the same problem, and the number of data is always a multiple of 10. But if I use postman, I can get all data I want. It is my first attempt to use java to connect es, I wonder if there are some tricks I should do to check my nodes or configuration file? – jiasheng123 Jul 02 '20 at 05:15
  • @jiasheng123 yeah please provide the node's configuration but are you getting this exception consistently while connecting through Java? – Amit Jul 02 '20 at 05:54
  • @jiasheng123 also can you provide the code, how you are creating Elasticsearch client and your elasticsearch config(no of data nodes) etc – Amit Jul 02 '20 at 06:02
  • I have checked cluster, it has two types of nodes, the client node and data node. When "client.transport.sniff" is set as "false" in java code, none of the data nodes is available, when it is set as "true", none of the client nodes is available. – jiasheng123 Jul 03 '20 at 05:42