弹性搜索中的范围值搜索,不返回结果

奇森

我有个问题。我已尝试进行大量查询,但都没有返回任何文档。

我的数据格式是这样的:

{
    "_index": "orders",
    "_type": "order",
    "_id": "AVad66hjiOD-asNwVILB",
    "_score": 1,
    "_source": {
      "document": {
        "orderID": "1337",
        "sku": "awesomeSku",
        "customerID": "7331",
        "productID": "20490859",
        "variantID": "97920239",
        "createTime": "2016-07-13T13:23:19Z",
        "retailPrice": "10000",
        "costPrice": "10000",
        "new": 123
      }
    }
  }

我的查询:

{
"query": { 
"bool": {
  "filter": [ 
    { "range": { "new": { "gte": "20" } } } 
  ]
}
  }
}

我只是想简单地从某个地方开始,找到所有属性为“ new”且值大于20的文档。任何反馈都很棒。

编辑:

ES中的数据格式:

{
 "orders": {
"mappings": {
  "order": {
    "properties": {
      "document": {
        "properties": {
          "costPrice": {
            "type": "string"
          },
          "createTime": {
            "type": "string"
          },
          "customerID": {
            "type": "string"
          },
          "new": {
            "type": "long"
          },
          "orderID": {
            "type": "string"
          },
          "productID": {
            "type": "string"
          },
          "retailPrice": {
            "type": "string"
          },
          "sku": {
            "type": "string"
          },
          "variantID": {
            "type": "string"
          }
        }
      }
    }
  }
  }
 }
 }

您需要在document.new字段上进行这样的查询,因为所有字段都嵌套在顶层document部分中:

{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "document.new": {
              "gte": 20
            }
          }
        }
      ]
    }
  }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章