1. Install Elasticsearch
Elasticsearch download address: http://www.elasticsearch.org/download/
・After downloading, decompress directly, enter the bin in the directory, run elasticsearch.bat under cmd to start Elasticsearch
・Use the browser to access: http://localhost:9200/. If the following results appear, the installation will be successful:
{ "name" : "Benedict Kine", "cluster_name" : "elasticsearch", "version" : { "number" : "2.2.0", "build_hash" : "8ff36d139e16f8720f2947ef62c8167a888992fe", "build_timestamp" : "2016-01-27T13:32:39Z", "build_snapshot" : false, "lucene_version" : "5.4.1" }, "tagline" : "You Know, for Search"} in:
・name---The name of the Elasticsearch instance. By default, it will randomly select one from the name list, and its setting is in the config/elasticsearch.yml file;
・version---version number, representing a set of information in json format, where:
The number field represents the version number of the currently running Elasticserch;
The build_snashot field represents whether the current version is built from source;
lucene_version represents the version of Lucene that Elasticsearch is based on;
・tagline--Contains the first tagline of Elasticsearch: "You Know, for Search".
2. RTF version
Beginners can start with the RTF version of Elastisearch. RTF is the abbreviation of Ready To Fly, a recommended engineering version that integrates basic plug-ins (such as service packaging, Chinese word segmentation, mapper-attachments, transport-thrift, tools.carrot2 and other plug-ins) and has sample programs that can be started directly.
Download address: https://github.com/medcl/elasticsearch-rtf
After decompression, you will see its directory structure. The main folders and functions contained in Elasticsearch are as follows (taking the TF version as an example):
・bin--Contains some scripts that run Elasticsearch instances and management plug-ins;
・config--mainly some settings files・lib--contains some related package files;
・plugins-include related plug-in files, etc.;
・logs--log file;
・data--where data is stored in Elasticsearch;
・works-temporary files.
3. Plug-in introduction and installation
1.Head
Head is a client plugin used to monitor the status of Elasticsearch.
Install: plugin install mobz/elasticsearch-head in the bin directory
After installation, enter: http://localhost:9200/_plugin/head/ in the browser, and the following interface will be opened:
The figure shows a node Benedict Kine. Each node has data of a different index, and the head provides an HTTP client.
2.Marvel
Marvel is Elasticsearch's graphical monitoring client, which can be used to view the current status of various items.
Install:
marvel exists as an elasticsearch plug-in, and can be installed directly through the plug-in:
# ./bin/plugin -i elasticsearch/marvel/latest
If you download the installation package from the official website, run:
# ./bin/plugin -i marvel file:///path/to/marvel-latest.zip
run:
Enter: http://localhost:9200/_plugin/marvel/ in the browser, and the following interface will be opened:
2. Build indexes with the help of Head
After starting Elasticsearch, visit: http://localhost:9200/_plugin/head/ in the browser to open the Head tool.
step1:
Click the "New Index" button to create a new index and enter the index name in the pop-up box, as shown in the figure below. The number of shards is 5 and is 0, 1, 2, 3, 4 in sequence. The data copy is 1,
See the following results in the overview that the index was successfully created. The sharded copy with a thick box in the figure is the provided copy of the data.
step2:
Under the "Any Request" tab of the Head tool, open the "Query" option, as shown in the figure below.
3. Query index
Or under the composite query label, select the GET operation type (equivalent to SELECT), as shown in the following figure, you can see the detailed information of the index file.
4. Operation instructions
Elasticsearch's head uses four request methods for the HTTP protocol, among which:
5. Brief description of Mapping
Mapping in Elasticsearch is similar to data types in static languages. But images have some other meanings, such as: executing a series of instructions to convert the input data into searchable index items, and using the image to query information of each field of a type file.
6. Information retrieval
Users can use the Head tool to construct a simple information retrieval statement through HTTP passing parameters. As shown in the figure below, specify the search request construction method of the search field in the share of myfirstindex index, and its value is Beijing.
The returned result can be seen in hits on the right side of the figure. Hits represents the search set of hits, total represents 2 records hits, and max_score is its score.
When the URL is constructed, _search means searching for the RESTful interface, q means query conditions, and = after q is a query expression based on Lucene syntax.