Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the elasticsearch syntax?

Shulou Source: shulou.com Published: 2022-06-01 12:46:17 10月03日 Update

This article mainly talks about "what is the grammar of elasticsearch". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what are the elasticsearch grammars?"

Grammar

/ / /

Command

Query all indexes GET / _ cat/indices

GET / _ cat/indices?v create index PUT / user delete index DELETE / user add document delete document query document GET / user/_searchname field contains "Zhang San" or "Li Si"

GET / user/_search

{

"query": {

"match": {"name": "Zhang San Li Si"}

}

"from": 0

"size": 20

"_ source": ["name"]

}

Match all documents GET / user/_search

{

"query": {

"match_all": {}

}

} all name fields, including GET / user/_search of "Zhang San"

{

"query": {

"match_phrase": {"name": "Zhang San"}

}

} bool query

Of all the data, the name field simultaneously

GET / user/_search including "Zhang San" and "Li Si"

{

"query": {

"bool": {

"must": [

{"match": {"name": "Zhang San"}}

{"match": {"name": "Li Si"}}

]

}

}

} bool query

Of all the data, the name field

GET / user/_search containing "Zhang San" or "Li Si"

{

"query": {

"bool": {

"should": [

{"match": {"name": "Zhang San"}}

{"match": {"name": "Li Si"}}

]

}

}

} bool query

Of all the data, the name field simultaneously

GET / user/_search that does not include "Zhang San" or "Li Si"

{

"query": {

"bool": {

"must_not": [

{"match": {"name": "Zhang San"}}

{"match": {"name": "Li Si"}}

]

}

}

} bool query

Of all the data, the name field

Includes "Zhang San" but does not include "Li Si" GET / user/_search

{

"query": {

"bool": {

"must": [

{"match": {"name": "Zhang San"}}

]

"must_not": [

{"match": {"name": "Li Si"}}

]

}

}

} filter query

Of all the data, 10

Tags: Query Zhang San Li Si fields data documents grouping grammar reverse order index statistics content at the same time average learning practical deeper interest command practicality Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Huawei NVidia Docker Shulou Tech Info