ElasticSearch
简介
MySql&ES 比较
安装
ES 安装
Let’s download the Elasticsearch 5.6.4 tar as follows:
Then extract it as follows:
It will then create a bunch of files and folders in your current directory. We then go into the bin directory as follows:
And now we are ready to start our node and single cluster:
Access http://localhost:9200/
ES API
Elastcsearch-head 安装
访问: http://localhost:9100/
ElasticSearch-Head 使用实践
创建索引模型
查看索引模型
创建索引
查询索引
更新索引
删除索引
ES 查询表达式
Query DSL
Elasticsearch provides a full Query DSL (Domain Specific Language) based on JSON to define queries. Think of the Query DSL as an AST (Abstract Syntax Tree) of queries, consisting of two types of clauses:
Leaf query clauses
Leaf query clauses look for a particular value in a particular field, such as the match, term or range queries. These queries can be used by themselves.
Compound query clauses
Compound query clauses wrap other leaf or compound queries and are used to combine multiple queries in a logical fashion (such as the bool or dis_max query), or to alter their behaviour (such as the constant_score query).
Allow expensive queries
Certain types of queries will generally execute slowly due to the way they are implemented, which can affect the stability of the cluster. Those queries can be categorised as follows:
Queries that need to do linear scans to identify matches:
Queries that have a high up-front cost:
fuzzy queries (except on wildcard fields)
regexp queries (except on wildcard fields)
prefix queries (except on wildcard fields or those without index_prefixes)
wildcard queries (except on wildcard fields)
range queries on text and keyword fields
Queries on deprecated geo-shapes
Queries that may have a high per-document cost:
The execution of such queries can be prevented by setting the value of the search.allow_expensive_queries
setting to false
(defaults to true
).
附录
GitHub
https://github.com/elastic/elasticsearch
Doc
https://www.elastic.co/guide/index.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html
Elasticsearch 权威指南
https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html
评论