忽略Elasticsearch中标记为已删除的记录

时间:2015-11-10 12:28:55

标签: elasticsearch

我只是在deleted_at null 为空时才尝试处理记录。我修改了原始查询,如下所示,但由于某种原因,结果不会改变。我还在删除记录。

我通过类似的SO问题阅读Exists FilterMissing FilterDealing with Null Values,但未能实现。

分析工具和制图

'settings' => [
    'index' => [
        'analysis' => [
            'analyzer' => [
                'snowball_analyzer' => [
                    'type' => 'snowball',
                    'language' => 'English',
                ],
            ],
        ],
    ],
],
'types' => [
    'mappings' => [
            'deleted_at' => ['type' => 'date'],
    ],
],

ORIGINAL QUERY

{
  "sort": {
    "_score": "desc"
  },
  "query": {
    "filtered": {
      "query": {
        "bool": {
          "must": [
            {
              "term": {
                "user_id": "35ee78ea"
              }
            },
            {
              "term": {
                "age": "44"
              }
            }
          ],
          "minimum_should_match": 1
        }
      }
    }
  }
}
  

missing filter基本上是存在的倒数:它返回   特定字段没有价值的文件

我的无效修改1

{
  "sort": {
    "_score": "desc"
  },
  "query": {
    "filtered": {
      "query": {
        "bool": {
          "must": [
            {
              "term": {
                "user_id": "35ee78ea"
              }
            },
            {
              "term": {
                "age": "44"
              }
            }
          ],
          "minimum_should_match": 1
        }
      },
      "filter": {
        "bool": {
          "must": [
            {
              "missing": {
                "field": "deleted_at"
              }
            }
          ]
        }
      }
    }
  }
}

我的无效修改2

{
  "sort": {
    "_score": "desc"
  },
  "query": {
    "filtered": {
      "query": {
        "bool": {
          "must": [
            {
              "term": {
                "user_id": "35ee78ea"
              }
            },
            {
              "term": {
                "age": "44"
              }
            }
          ],
          "minimum_should_match": 1
        }
      },
      "filter": [
        {
          "missing": {
            "field": "deleted_at"
          }
        }
      ]
    }
  }
}

0 个答案:

没有答案
相关问题