Elasticsearch异常

时间:2016-09-30 05:05:35

标签: elasticsearch

我正在尝试在ElasticSearch中进行搜索,但它发出错误:

[failed to parse search source[{
    "sort": {
        "sorter": {
            "order": "desc",
            "mode": "max"
        }
    },
    "query": [{
        "match": {
            "muteFeedUserIds": "56f4ca2f44fc8650411170b0"
        }
    }, {
        "match": {
            "approvalStatus": "approved"
        }
    }],
    "filter": {
        "range": {
            "sorter": {
                "to": "2016-06-28",
                "include_upper": false
            }
        }
    }
}]];
nested: ElasticsearchParseException[failed to parse search source.expected field name but got[START_OBJECT]];

知道我错过了什么吗?

由于

2 个答案:

答案 0 :(得分:0)

请尝试此查询:

{
  "sort": {
    "sorter": {
      "order": "desc",
      "mode": "max"
    }
  },
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "muteFeedUserIds": "56f4ca2f44fc8650411170b0"
          }
        },
        {
          "match": {
            "approvalStatus": "approved"
          }
        }
      ],
      "filter": {
        "range": {
          "sorter": {
            "to": "2016-06-28",
            "include_upper": false
          }
        }
      }
    }
  }
}

答案 1 :(得分:0)

嗨尝试以下方法(它也是更快的方式,而不是使用过滤器):

%x(python -c 'print __import__("sys").version_info < (2,8)') == "True\n"

这绝对可以解决您的错误。