Nexcess Cloud & Managed Apps: Optimize using Elasticsearch Containers & API! Enable a fast, scalable, open source search engine for large amounts of data!
Elasticsearch is a fast, scalable, open source search engine for large amounts of structured and unstructured data. Elasticsearch can be used for a variety of applications, and it is required for recent versions of Magento.
Elasticsearch containers are external instances of Elasticsearch within the Nexcess cloudhost network that are running in docker containers with minimal overhead. When they are enabled in the Nexcess portal for your application, an endpoint and port are provided that will be needed in order to utilize the API commands described below. Here is an example endpoint and port:
This tutorial will cover some basics of how to use the Elasticsearch API with Nexcess Managed Apps cloud containers. This covers how to connect and check uptime, verify resource usage, and change some settings for the Elasticsearch container.
Nexcess Elasticsearch containers are not accessible from outside the internal network, and so it’s necessary to log in via SSH to the cloudhost account to connect to it directly. Next, check for a simple response using the following curl command, replacing with actual endpoint and port found in portal under Plans > Plan Dashboard > Containers:
Heap size: current memory usage and percent of total:
Response will look something like the following. Here 624.9mb are in use by the container, or 62% of the total available (1G):
This is pretty self-explanatory; the response should give the total uptime of the container:
Elasticsearch “Yellow” Status
If the health statuses of the container indices are reporting as yellow, or logs are showing the error 'the shard cannot be allocated to the same node on which a copy of the shard already exists', the yellow status will not actually cause any issues because the container is running as a single node and so there are no replicas. The number_of_replicas setting is set to 1 by default, but it can be changed to 0 using the Elasticsearch API. Example of yellow status:
Here is an example of how to check the current ‘number_of_replicas’ for the indices:
Setting 'number_of_replicas' to 0 for the indices will lead to Elasticsearch reporting green status, as long as there isn't another resource issue causing yellow/red status:
If container was just enabled, wait at least 15 minutes to allow for the DNS record for the elasticsearch endpoint to propagate.
Assuming 15 minutes has elapsed, support may need to assist if connection is failing.
There is quite a bit more that can be done with the Elasticsearch API, both in terms of changing default settings and more complex queries. Below are a few links to documentation that can be starting points for a deeper dive.
Need more help? The Applications > Control Panel Tools > Client Portal sections within the Nexcess Knowledge Base are important resources for those seeking additional knowledge. Or, check out our related articles below.
Our award-winning customer care team is here for you.Contact Support