A few concepts
1, Index Type Document
And usually when we’re starting out, we’re going to compare this to a database to make sense of it
- Index->Database
- Type->Table (The latest version no longer uses Type, so many people will wonder why? ES is not the same as a database, so don’t just think of ES as a database.)
- Document->Row
2, inverted index
Refer to this article :(generally, we find the corresponding article from the table of contents as the forward index, if we find the corresponding article from the keyword index, that is, the inverted index)
ES index analysis (| inverted index structure is row index)
Two, several Java call ES way
- Rest API Test
- Using Spring Data Repositories
- Using the RestClient
- Using Transport Client
Rest API Test
Refer to official documentation:
[www.elastic.co/guide/en/el…
www.elastic.co
] (link.zhihu.com/?target=htt…).
_doc PUT /index-test/_doc/1 {"id":"1", "name": "id":"1", "name": "Hello world", "code":11} # #e.g. POST /index name /_doc/document id POST /index-test/_doc/1 {"id":"1", "name": "hello world", GET /index-test/_search {"query": Match match_phrase match_phrase_prefix = match_phrase_prefix = match_phrase_prefix = match_phrase_prefix = match_phrase_prefix = match_phrase_prefix = match_phrase_prefix W is not a complete word or phrase. #match_phrase contains word match, phrase match #e.g #match_phrase_prefix contains word matching, phrase matching, and wildcard matching #e.g #match match_phrase_prefix = "hello wadasas match" GET /index-test/_search {"query": {"match": {"name": GET /index-test/_search {"query": {"term": {"name": {"term": {"name": GET /index-test/_search {"query": {"terms": {"name": ["hello","world"]}} # 4, 用 法 分词 iK # support 2 types of word segmentation ik_smart ik_max_word # test 分词 segmentation _analyze GET /index-test/_analyze { "Analyzer" : "ik_max_word", "text" : "your world"} # 8, sorting, and paging GET/bank / _search {" query ": {" match_all" : {}}, "sort" : [{"age": "asc"}], "from": 1, "size": 1} # { "properties":{ "message": { "analyzer": "ik_smart", "type": "Text "," fieldData ":"true"}}}} # add doc1 PUT /message_index/_doc/1 {"message": } # add doc2 PUT /message_index/_doc/2 {"message":"ES is not the same as database, POST /message_index/_search {"size" : 0, "aggs" : { "messages" : { "terms" : { "size" : 10, "field" : "message" } } } }Copy the code
Java Elasticsearch 7.10 tutorial
Java Elasticsearch 7.10
zhuanlan.zhihu.com] (zhuanlan.zhihu.com/p/321248369)