作者: 石文
时间:2019-04-02
过滤器种类
范围过滤器
{
"post_filter":{
"range":{
"year":{
"gte":1930,
"lte":1990
}
}
}
}
exists过滤器:过滤掉给定字段没有值的文档
{
"post_filter":{
"exists":{
"field":"year"
}
}
}
missing过滤器
{
"post_filter":{
"missing":{ #过滤掉给定字段有值或缺失的文档
"field":"year",
"null_value":0,
"existence":true
}
}
}
脚本过滤器
{
"post_filter":{
"script":{ #过滤掉发表在一个世纪以前的书
"script":"now - doc['year'].value > 100",
"params":{"now":2012}
}
}
}
类型过滤器
{
"post_filter":{
"type":{
"value":"book"
}
}
}
限定过滤器
{
"post_filter":{
"limit":{
"value":1
}
}
}
标识符过滤器
组合过滤器
{
"query": {
"bool": {
"must": {
"range": {
"year": {
"gte": 1930,
"lte": 1990
}
}
},
"should": {
"term": {
"available": true
}
},
"boost": 1
}
}
}