This topic provides answers to some frequently asked questions about using a client to access an Elasticsearch cluster.
Is Alibaba Cloud Elasticsearch compatible with open source Elasticsearch APIs?
Can I use a Java API to access an Alibaba Cloud Elasticsearch cluster over port 9200?
Is Alibaba Cloud Elasticsearch compatible with open source Elasticsearch APIs?
Alibaba Cloud Elasticsearch supports RESTful APIs provided by open source Elasticsearch and provides a dedicated management API.
Alibaba Cloud Elasticsearch is fully compatible with the RESTful APIs provided by open source Elasticsearch. You can use the RESTful APIs to manage data in a cluster. For example, you can add documents, remove documents, modify documents, search for data, or configure aliases. For more information, see Restful API.
Alibaba Cloud Elasticsearch provides a dedicated management API. You can call the API to implement operations that you can perform in the Alibaba Cloud Elasticsearch console. For example, you can create a cluster or configure an IP address whitelist for a cluster. For more information, see List of operations by function.
How do I configure the cluster.name parameter when I use Transport Client to access an Alibaba Cloud Elasticsearch cluster?
Set the cluster.name parameter to the ID of the cluster. You can obtain the ID from the Basic Information page of the cluster. For more information, see View the basic information of a cluster.
When I use Transport Client to access an Alibaba Cloud Elasticsearch cluster, the error message "NoNodeAvailableException" is displayed. What do I do?
The error message returned because Transport Client 5.5 or 5.6 is used. We recommend that you use Transport Client 5.3.3 to access an Alibaba Cloud Elasticsearch cluster. You can use Transport Client to access only Alibaba Cloud Elasticsearch V5.5 or V5.6 clusters. When you use Transport Client, set the client.transport.sniff
parameter to false. For more information, see Transport Client (5.x).
Transport Client falls into disuse in open source Elasticsearch 7.0. We recommend that you use Java REST clients. For more information about Java REST clients, see High Level REST Client (6.3.x), High Level REST Client (6.7.x), and Low Level REST Client (5.x).
What do I do if the error message "Client Request Timeout" is displayed when I use a client to access an Alibaba Cloud Elasticsearch cluster?
The following table describes the possible causes of this issue and the related solutions.
Possible cause | Solution |
The memory of the Elasticsearch cluster is insufficient. As a result, read and write I/O operations are blocked. | View the monitoring data of the Elasticsearch cluster to obtain the memory usage and the read and write workloads of the cluster. If the memory of the cluster is insufficient and the read and write workloads of the cluster are heavy, we recommend that you appropriately reduce the number of read and write operations to improve read and write performance. |
You specify a short connection timeout period. As a result, timeout occurs before a connection between the client and the Elasticsearch cluster is established. | Adjust the value of the ConnectTimeout parameter and the value of the SocketTimeout parameter on the client based on your business requirements. For example, you can change the value of the ConnectTimeout parameter to 10000 and the value of the SocketTimeout parameter to 30000. |
Network issues such as network fluctuations occur. | Resolve the issues based on the actual situation. |
Can I use a Java API to access an Alibaba Cloud Elasticsearch cluster over port 9200?
Yes, you can use a Java API to access an Elasticsearch cluster over port 9200. Alibaba Cloud Elasticsearch allows you to use all Java APIs supported by open source Elasticsearch to access Alibaba Cloud Elasticsearch clusters of all versions over port 9200. If you want to access an Alibaba Cloud Elasticsearch V5.X cluster, you can also use Transport Client 5.3.3 to access the cluster over port 9300. If you want to access an Alibaba Cloud Elasticsearch cluster of V6.0 or later, port 9300 is unavailable due to its potential security risks, and only port 9200 is available. Alibaba Cloud Elasticsearch does not allow you to access a cluster over a custom port.
You can use only the SDK of Transport Client 5.3.3 to access Elasticsearch V5.X clusters because of the bugs of the SDK of Transport Client 5.5.3. You must set the client.transport.sniff parameter to false in the code that is used to access an Elasticsearch V5.X cluster. For more information about Transport Client, see Transport Client (5.x).
What do I do if the error message "Connection reset by peer" is displayed when I use a client to access an Alibaba Cloud Elasticsearch cluster?
Cause
Read and write operations are performed after the client is unexpectedly disconnected from the Elasticsearch cluster.
Solutions
You can perform the following checks to resolve the issue:
View the logs and monitoring data of the Elasticsearch cluster to check whether exceptions occur on the cluster.
If issues such as unhealthy cluster status and node disconnection occur on the cluster, resolve the issues first. For information, see Metrics and exception handling suggestions.
Check whether a network interception policy is configured for the client.
You can enable the system to capture packets from the user side, Elasticsearch service side, and Server Load Balancer (SLB) service side to troubleshoot network issues. If no network issues occur on the sides, you must check whether a network interception policy is configured for the client.
Check whether the TCP connection that is established based on HTTP keep-alive times out.
HTTP keep-alive ensures that a single TCP connection can transfer packets between the server and client as many as possible. Each time a packet is transferred between the server and client, the duration of the TCP connection established based on HTTP keep-alive is updated. If no packets are transferred between the server and client during a specific period of time, the TCP connection times out. In this case, HTTP keep-alive releases and closes the TCP connection.
NoteTCP keep-alive is a keepalive mechanism that is used to detect the status of a TCP connection. In theory, if no exceptions occur on the server and client after a TCP connection is established, the TCP connection permanently exists unless it is closed. HTTP keep-alive ensures that a single TCP connection can transfer packets between the server and client as many as possible. If no packets are transferred between the server and client during a specific period of time, HTTP keep-alive releases and closes the TCP connection.
If the TCP connection established based on HTTP keep-alive times out, you can increase the connection timeout period. For example, you can change the value of the ConnectTimeout parameter to 10000 and the value of the SocketTimeout parameter to 30000 on the client.
If the issue persists after you perform the preceding checks, you can check whether the code logic is correct, retry the connection, and analyze the issue based on the actual situation.
How do I install the cURL tool and use a cURL command to access an Alibaba Cloud Elasticsearch cluster if I want to use a Windows client to connect to the cluster?
Download the package for the cURL tool and install the cURL tool. You can obtain the package from cURL documentation.
Run a cURL command to access the Elasticsearch cluster. For more information, see Use cURL commands and API operations to manage an Alibaba Cloud Elasticsearch cluster.
Which SQL query methods are supported when I use a client to access an Alibaba Cloud Elasticsearch cluster?
A client that is used to access an Alibaba Cloud Elasticsearch cluster supports the same features as a client that is used to access an open source Elasticsearch cluster. In addition, the use methods of the features for the two clients are the same. The following SQL query methods are supported:
SQL query methods such as SQL REST API, SQL Translate API, and SQL JDBC driver. For more information about the supported SQL query methods, see SQL Client Applications. Elasticsearch clusters of V6.3 or later support X-Pack SQL.
X-Pack SQL queries. You can use the x-pack-sql plug-in provided by Elastic. For more information, see sql-search-api.
Third-party SQL plug-ins, such as the open source plug-in elasticsearch-sql. For more information about the plug-in, see elasticsearch-sql.