Where is the main class for opensearch-cli?

Hi there, new OpenSearch user here trying to use the cli for the first time. I have a new cluster formed and it seems to be working.

I can’t seem to get the cli to execute properly. It seems like the variable for $OPENSEARCH_MAIN_CLASS is never populated when executing the opensearch-cli script.

The command that is generated when executing opensearch-cli --version is below:

/usr/share/opensearch/jdk/bin/java -Xshare:auto -Xms4m -Xmx64m -XX:+UseSerialGC -Dopensearch.path.home=/usr/share/opensearch -Dopensearch.path.conf=/usr/share/opensearch/config -Dopensearch.distribution.type=tar -cp /usr/share/opensearch/lib/* --version

Note how there is an empty value for $OPENSEARCH_MAIN_CLASS. I can’t see anywhere that this variable is populated in the script, so I am perplexed. Since it doesn’t find the class, this is always what my output is:
Error: Could not find or load main class
Caused by: java.lang.ClassNotFoundException

Assistance is definitely appreciated

1 Like

There are actually two opensearch-cli’s

Are you talking about:
https://github.com/opensearch-project/OpenSearch/blob/main/distribution/src/bin/opensearch-cli

Or

https://github.com/opensearch-project/opensearch-cli

I’m using the Java version bundled with the tarball under $OPENSEARCH_HOME/bin. I wasn’t aware there was a GoLang version.

Which version will be supported?

Two totally different use cases. So… both? I hate the name clash (and I’ve brought it up previously) but I think we’re stuck with it for a while.

opensearch-cli (golang) is CLI tool for working with OpenSearch clusters (think of an command line version of OpenSearch Dashboards)

All this being said, I’m going to move this conversation to the correct category.

@searchymcsearchface do you know where $OPENSEARCH_MAIN_CLASS is populated?

bin/opensearch-cli is a script that has the common logic for all other tools in the bin directory, e.g. opensearch-plugin (https://github.com/opensearch-project/OpenSearch/blob/main/distribution/src/bin/opensearch-plugin)

So opensearch-cli that is bundled with the distribution is not a tool but rather a helper script.

1 Like

@rabi well, that’s not the least bit confusing :slight_smile: Thanks for clearing it up though.

1 Like