全查询
GET /school/student/_search
{
"query": {
//todo query
}
}
TermQuery词元使用
GET /school/student/_search
{
"query": {
"term": {
"about": {
"value": "travel"
}
}
}
}
FuzzyQuery模糊查询使用
GET /school/student/_search
{
"query": {
"fuzzy": {
"about": {
"value": "travle"
}
}
}
}
PrefixQuery 通过前缀查询
GET school/student/_search
{
"query": {
"prefix": {
"about": {
"value": "tr"
}
}
}
}
WildcardQuery 通配符查询
GET school/student/_search
{
"query": {
"wildcard": {
"about": {
"value": "*"
}
}
}
}
BooleanQuery组合查询
GET school/student/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"about": {
"value": "travel"
}
}
}
],
"must_not": [
{"term": {
"sex": {
"value": "girl"
}
}}
],
"filter": {
"term": {
"name": "zhangfei"
}
}
}
}
}
通过分词器进行查询parser
GET school/student/_search
{
"query": {
"match": {
"about": "travel history"
}
}
}
通过分词器进行多字段查询
GET school/student/_search
{
"query": {
"bool": {
"should": [
{ "match": {
"about": "i like travel"
}},
{
"match": {
"name": "zhangfei"
}
}
]
}
}
}