Introduction to the

ElasticSearch is a Lucene-based search server. It provides a distributed multi – user – capable full – text search engine based on RESTful Web interface.

Install the elasticsearch

The brew install [email protected]Copy the code

1. The result:

2. Start, close, and restart es

Brew Services start [email protected] brew Services stop [email protected] Brew Services restart [email protected]Copy the code

3. Data filling method (I used Postman in the test)

Install the elasticsearch – head

1. Purpose: Used to view the status and information (or data) of ES.

2. Github address: elasticSearch-head

I installed Chrome Extension as follows:

Running as a Chrome extension

Install ElasticSearch Head from the Chrome Web Store.
Click the extension icon in the toolbar of your web browser.
Copy the code

3. The result:

Install the elasticsearch – SQL

1. Purpose: Use general SQL to query and aggregate ES

2. Making address: elasticsearch – SQL

3. Install the plug-in by following the commands in the ES version manual. For example, my installation command is:

elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/5.6.8.0/elasticsearch-sql-5.6.8.0.zip
Copy the code

4. Usage

  • Use the API interface for operations
http://localhost:9200/_sql?sql=select * from song001/list001
Copy the code
  • Operations using the Web view refer to the official website
On elasticsearch 5.x/6.x, download and extract site.
Then start the web front-end like this:
cd site-server
npm install express --save
node node-server.js 
Copy the code

So download the zip package and unzip it to your own directory, such as mine:

Then follow the instructions in the manual. (Please install Node in advance ~~)

  • The Web view needs to be installedhttp-proxy-middlewareThe agent

Github address: http-proxy-middleware

Run node node-server.js after modifying the node-server.js code

var express = require('express');
var proxy = require('http-proxy-middleware');
var app = express();
app.use(express.static('.. /_site'));
app.use('/_sql', proxy({target: 'http://localhost:9200/', changeOrigin: true}));

app.get('/'.function (req, res) {
    res.sendFile(".. /_site/" + "index.html" );
})
var fs = require('fs');
var siteConfiguration = JSON.parse(fs.readFileSync('site_configuration.json'.'utf8'));
var server = app.listen(siteConfiguration.port)

// var express = require('express');
// var app = express();
// app.listen(3000);
Copy the code
  • Web view to view data

manual

https://www.elastic.co/guide/en/elasticsearch/guide/master/create-doc.html

Pay attention to the point

  • Select id, name from table group by name; select id from table group by name;
  • Paging data is a bit cumbersome.
  • When group by has multiple fields, the return value is a tree structure.

supplement

The first pit, later will supplement in ES aggregation operations and full text search.

reference

  1. Github.com/NLPchina/el…
  2. www.elastic.co/guide/en/el…
  3. Github.com/mobz/elasti…