Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of elasticsearch kibana query

Shulou Source: shulou.com Published: 2022-06-03 14:51:11 11月03日 Update

Editor to share with you the example analysis of elasticsearch kibana query, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

1. Simple CRUD operation

1. Add

PUT / index/type/id {"json data"}

2. Query

GET / index/type/id

3. Modification

POST / index/type/id/_update {"doc": {"FIELD": "value"}}

4. Delete

DELETE / index/type/id

Second, search

Search can be divided into six categories

1 、 query string search

2 、 query DSL

3 、 query filter

4 、 full-text search

5 、 phrase search

6 、 highlight search

1 、 query string search

Search all: GET supplier/user/_search

{"took": 2, "timed_out": false, "_ shards": {"total": 5, "successful": 5, "failed": 0}, "hits": {"total": 3, "max_score": 1, "hits": [{"_ index": "supplier", "_ type": "user", "_ id": "2", "_ score": 1 "_ source": {"name": "lisi", "age": 26, "address": "bei jing tong zhou", "price": 10000, "dept": ["kaifabu"]}}, {"_ index": "supplier", "_ type": "user", "_ id": "1", "_ score": 1 "_ source": {"name": "zhangsan", "age": 30, "address": "bei jing chang chun jie", "price": 15000, "dept": ["kaifabu", "yanfabu"]}}, {"_ index": "supplier", "_ type": "user", "_ id": "3" "_ score": 1, "_ source": {"name": "wangwu", "age": 26, "address": "bei jing tong zhou yun he ming zhu", "price": 13000, "dept": ["kaifabu"]}

Took: it took a few milliseconds

Timed_out: whether or not to time out, there is no such thing.

_ shards: the data is split into 5 shards, so for search requests, all primary shard will be hit (or one of its replica shard will also work)

Hits.total: number of query results, 3 document

The meaning of hits.max_score:score is the matching score of document for the relevance of a search. The more relevant it is, the more matching it is, and the higher the score.

Hits.hits: contains detailed data of the document that matches the search

2 、 query DSL

Query all

GET supplier/user/_search {"query": {"match_all": {}

Query all and sort

GET suppluer/user/_search {"query": {"match_all": {}}, "sort": [{"price": {"order": "desc"}]}

Paging query

GET supplier/user/_search {"query": {"match_all": {}}, "from": 1, "size": 1}

Specify the field to query the display

GET supplier/user/_search {"query": {"match_all": {}}, "_ source": ["name", "price"]}

3 、 query filter

Search for those whose name is' lisi' and whose price is greater than 1500

GET supplier/user/_search {"query": {"must": {"match": {"name": "lisi"}}, "filter": {"range": {"price": {"gt": 1500}

4. Full-text search (full-text search)

The address field will be disassembled first to create an inverted index.

GET / ecommerce/product/_search {"query": {"match": {"address": "bei jing"}

5. Phrase search (phrase search)

Corresponding to full-text retrieval, full-text retrieval will disassemble the input search string and match it one by one in the inverted index. As long as it can match any of the disassembled words, it can be returned as a result.

Phrase search, which requires that the search string entered must be exactly the same in the specified field text before it can be considered a match and returned as a result.

GET / ecommerce/product/_search {"query": {"match_phrase": {"address": "bei jing"}

6. Highlight search (highlight search results)

GET / ecommerce/product/_search {"query": {"match": {"address": "bei jing"}}, "highlight": {"fields": {"address": {} these are all the contents of the article "sample Analysis of elasticsearch kibana query". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Search query results full-text full-text search data article disassembly retrieval example analysis content score field index input exactly the same not much word meaning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Docker vpn macOS Linux