What is the elasticsearch syntax?
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