1.我们往kibana插入数据,来进行查询
POST /t1/_doc/
{
"name":"cat",
"age":"18",
"address":"BJ",
"job":"dev"
}
POST /t1/_doc/
{
"name":"dog",
"age":"19",
"address":"SD",
"job":"ops"
}
POST /t1/_doc/
{
"name":"alice",
"age":"20",
"address":"BJ",
"job":"dev"
}
POST /t1/_doc/
{
"name":"tigger",
"age":"20",
"address":"AH",
"job":"ops"
}
POST /t1/_doc/
{
"name":"fix",
"age":"21",
"address":"HN",
"job":"dev"
}
POST /t1/_doc/
{
"name":"jack",
"age":"18",
"address":"BJ",
"job":"dev"
}
POST /t1/_doc/
{
"name":"Tom",
"age":"21",
"address":"HN",
"job":"ops"
}
2.查询
GET t1/_search
GET t1/_search
{
"query": {
"term": {
"name.keyword": {
"value": "cat"
}
}
}
}
GET t1/_search
{
"query": {
"term": {
"address.keyword": {
"value": "BJ"
}
}
}
}
bool组合语法
must:必须符合,包含 与AND等价
should:满足任意的条件, 与or等价
filter:必须满足,是否命中,不计算分值,等同must
must_not: 必须不符合不包含 与not等价
GET t1/_search
{
"query": {
"bool": {
"must": [
{"match": {
"job": "ops"
}}
],
"filter": [
{
"range": {
"age.keyword": {
"gte": 19,
"lte": 20
}
}
}
]
}
}
}
结果
3通过elassearch插件查询,找出北京,年纪为20岁的