In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what are the advantages of Elasticsearch7". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the advantages of Elasticsearch7"?
The biggest difference between Elasticsearch7 and previous versions is that it abandons the concept of type, and the default type is "_ doc".
Index first
PUT / shop
Dynamic, strict is recommended
When dynamic is set to true, when the document of the new field is written, Mapping is updated at the same time
When dynamic is set to false, Mapping will not be updated and the data of the new fields cannot be indexed, but will appear in _ source
If dynamic is set to strict, the document will fail to write.
Modify dynamic parameters
POST / shop/_mapping {"dynamic": strict}
The text type can be participle, but the keyword participle cannot be used. It should be fully matched.
Modify or add mapping field type
POST / shop/_mapping {"properties": {"name": {"type": "text",}, "content": {"type": "text", "analyzer": "ik_max_word" Search_analyzer: "ik_smart"}, "createTime": {"type": "date", "format": "yyyy-MM-dd HH:mm:ss"}
New data:
-POST shop/_doc/558pa4e2 {"name": "round-neck Korean version of students' sweaters for men and women in autumn and winter", "breif": "about 150 round-neck Korean version of students' sweaters for men and women in autumn and winter Long-sleeved loose-fitting sweater tops for couples "," minPrice ":" 15 "," sn ":" 558pa4e2 "," createTime ":" 2019-10-07 14:30:23 "," sort ":" 100th "," tags ":" September second wave "}
Add an alias to the index
-POST / _ aliases {"actions": [{"add": {"index": "shop-item", "alias": "shop-item-alias"}]}
Word Separator Test:
POST / _ analyze {"analyzer": "ik_smart", "text": "notice on speeding up the Construction of Hefei Metro Line 7"}
Single-field query: query data with "women's wear" in name
POST / shop/_doc/_search {"query": {"match": {"name": "Women's wear"}
Single-field query: query data with "women's wear" in name, and only return name and brief data
POST / shop/_doc/_search {"query": {"match": {"name": "women's wear"}}, "_ source": ["name", "brief"]}}
Paging query
POST / shop/_doc/_search {"query": {"match": {"name": "women's wear"}}, "_ source": ["name", "brief"], "from": 0, "size": 10}
Sort, query the data with "women's wear" in name, and press createTime in reverse order.
{"query": {"match": {"name": "women's wear"}, "sort": {"createTime": {"order": "desc"}
Multi-field sort, sort, query the data with "women's wear" in name, sort by sort field first, and then in reverse order by createTime if the same.
{"query": {"match": {"name": "women's wear"}, "sort": {"sort": "asc", "createTime": "desc"}}
Query all data that contains "women's wear" and "brand" in the "name" field
POST / shop/_doc/_search {"query": {"bool": {"must": [{"match": {"name": "Brand"}} {"match": {"name": "Women's wear"}
Query all data that contains "women's wear" or "brand" in the "name" field
POST shop/_doc/_search {"query": {"bool": {"should": [{"match": {"name": "Brand"}} {"match": {"name": "Women's wear"}
The query "name" field contains neither "women's wear" nor "brand" data.
POST / shop/_doc/_search {"query": {"bool": {"must_not": [{"match": {"name": "Brand"}} {"match": {"name": "Women's wear"}
Multi-field query: query data with "women's wear" in name and brief
POST / shop/_doc/_search {"query": {"multi_match": {"query": "women's wear", "fields": ["name", "brief"]}
Precise search: find data that tags belongs to both "September first wave" and "September second wave" (terms is used for precise search, generally used for non-text fields)
POST / shop/_doc/_search {"query": {"bool": {"must": [{"term": {"tags": "the first wave of September"}} {"term": {"tags": "second wave of September"}]}
The use of filter, filter is efficient, use filter as much as possible
POST / shop/_doc/_search {"query": {"bool": {"filter": [{"term": {"tags": "the first wave of September"}} {"term": {"tags": "second wave of September"}]}
Range query
POST / shop/_doc/_search {"query": {"range": {"minPrice": {"gte": "4", "lte": "5"}}
Simple aggregation
POST / shop/_doc/_search {"aggs": {"tagsGroup": {"terms": {"field": "tags"}} "priceGroup": {"terms": {"field": "minPrice"}} so far I believe that you have a deeper understanding of "what are the advantages of Elasticsearch7?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.