background

Elasticsearch is a popular text search database that was used in the project in 2014, but has since been used less frequently. Elasticsearch was used in one of the company’s products throughout the year, but I didn’t pay attention to the backend code because I had been writing the front-end for a while.

This article is a summary of the exceptions encountered during the operation of Elasticsearch.

Start with source code

After compiling the source code, you can start it directly from the source code. When gradlew run is executed for the first time, it starts successfully and closes the console. When you run the command again, an error occurs:Repeat execution multiple timesgradlew runThis error is reported later, and the solution is to execute it firstgradle cleanTo run again. I solved the problem by guessing from the exception information and then doing it.

Elasticsearch is now available as a backend process, even if the DOS console is closed.

Find ES process

The Elasticsearch process has started.

Curl Command single quotes VS double quotes

In Windows, do not use single quotation marks when using the curl command. Otherwise, an error will be reported. If -d does not accept multiple lines of JSON data, curl must use one line of data. The double quotes of JSON data are escaped.

Create the index and view the index type

Curl requests must be in double quotation marks under Windows

No document ID error is reporteduse_bulkWhen the interface inserts data in JSON files in batches, a new line is required for each line of data read, and the ID is specified in the first line.

{"_index": {"_id":"xxx"}}
{"name":"zhang"."account":"11111"."balance":123}
Copy the code