elasticsearch 1.7中的嵌套筛选器工作不正常

wz8daaqr  于 2021-06-10  发布在  ElasticSearch
关注(0)|答案(1)|浏览(363)

我无法使嵌套的过滤器排序正常工作。我有这样的Map-

"metadata": {
      "type": "nested",
      "include_in_parent": true,
      "properties": {
        "property": {
          "type": "string",
          "index" : "not_analyzed",
          "include_in_parent" : false,
          "include_in_all" : false
        },
        "type": {
          "type": "string",
          "index": "not_analyzed"
        },
        "value": {
          "type": "string",
          "fields": {
            "lower_case_sort": {
              "type": "string",
              "analyzer": "case_insensitive_sort"
            }
          }
        }
      }
    },

因此,每个文件都有属性为“duration”的元数据,值为duration值,例如50.300。这里我有一个查询,我正在做,但它不是返回结果上升或下降,它是随机的。

"query": {
    "bool": {
      "must": {
          "term" : {
                "parent.raw": "folderName"
           }
      }
    }
  },
  "size": 50,
  "from": 0,
  "sort": {
        "metadata.value": {
            "order":"desc",
            "nested_filter": {
                "term": { "metadata.property":"duration" }
            }
        }
    }
}

What could be the issue?

Thank you!
njthzxwz

njthzxwz1#

嵌套的\u路径和嵌套的\u过滤器选项已被弃用,取而代之的是6.1以上所述的选项。
尝试下面的搜索查询

{
  "query": {
    "bool": {
      "must": {
        "term": {
          "parent.raw": "folderName"
        }
      }
    }
  },
  "sort": [
    {
      "metadata.value": {
        "order": "asc",
        "nested": {
          "path": "metadata",
          "filter": {
            "term": {
              "metadata.property": "duration"
            }
          }
        }
      }
    }
  ]
}

相关问题