Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/416.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 搜索错误:[分析\u异常]无法分析搜索源。应为字段名,但得到[START\u OBJECT]_Javascript_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch,Javascript,elasticsearch" /> elasticsearch,Javascript,elasticsearch" />

Javascript 搜索错误:[分析\u异常]无法分析搜索源。应为字段名,但得到[START\u OBJECT]

Javascript 搜索错误:[分析\u异常]无法分析搜索源。应为字段名,但得到[START\u OBJECT],javascript,elasticsearch,Javascript,elasticsearch,我有一个查询解析异常。我正在使用javascript。我的配置在elastic.js文件中 如果删除过滤的部分,我将得到结果。但是如果我加上它,我会得到一个例外 var client = require('./elastic.js'); client.search({ index: 'test-2017.03.25', size: 0, body: { query: { bool: { must:

我有一个查询解析异常。我正在使用javascript。我的配置在elastic.js文件中

如果删除过滤的部分,我将得到结果。但是如果我加上它,我会得到一个例外

var client = require('./elastic.js');

client.search({
    index: 'test-2017.03.25',
    size: 0,
    body: {
        query: {
            bool: {
                must: {
                    match: {
                        status: 502,
                    }
                },

            },
            filtered: {
                query: {
                    range: {
                        timestamp: {'gt': 1490380200000}
                    }
                }
            }
        }
    }
}, function (error, response, status) {
    if (error) {
        console.log("search error: " + error)
    }
    else {
        console.log("--- Response ---");
        console.log(response);
        console.log("--- Hits ---");
        response.hits.hits.forEach(function (hit) {
            console.log(hit);
        })
    }
});
这是我的对象映射:

"test-2017.03.02": {
    "mappings": {
      "log": {
        "properties": {
          "@timestamp": {
            "type": "date",
            "format": "strict_date_optional_time||epoch_millis"
          },
          "@version": {
            "type": "string"
          },
          "beat": {
            "properties": {
              "hostname": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "body_bytes_sent": {
            "type": "string"
          },
          "count": {
            "type": "long"
          },
          "fields": {
            "properties": {
              "label": {
                "type": "string"
              }
            }
          },
          "host": {
            "type": "string"
          },
          "http_referrer": {
            "type": "string"
          },
          "http_user_agent": {
            "type": "string"
          },
          "input_type": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "offset": {
            "type": "long"
          },
          "remote_addr": {
            "type": "string"
          },
          "remote_user": {
            "type": "string"
          },
          "request": {
            "type": "string"
          },
          "request_method": {
            "type": "string"
          },
          "request_time": {
            "type": "double"
          },
          "source": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "tags": {
            "type": "string"
          },
          "time": {
            "type": "string"
          },
          "type": {
            "type": "string"
          }
        }
      }
    }
  }
我希望根据状态和请求获取数据,并使用timestamp字段进行过滤

我得到以下错误:

搜索错误:[分析\u异常]无法分析搜索源。应为字段名,但得到[START\u OBJECT]

请帮忙

样本文件:


您的查询无效,请将其更改为:

client.search({
    index: 'test-2017.03.25',
    size: 0,
    body: {
        query: {
            bool: {
                filter: [
                  {
                    match: {
                        status: 502,
                    }
                  },
                  {
                    range: {
                        '@timestamp': {'gt': 1490380200000}
                    }
                  }
                ]
            }
        }
    }

它工作了,但没有得到任何点击。我正在添加一个示例文档。你能提供一个查询来获得相似的文档吗?请随意分享一个应该匹配的示例文档。根据你的映射,查询时间戳的范围应该是@timestamp
client.search({
    index: 'test-2017.03.25',
    size: 0,
    body: {
        query: {
            bool: {
                filter: [
                  {
                    match: {
                        status: 502,
                    }
                  },
                  {
                    range: {
                        '@timestamp': {'gt': 1490380200000}
                    }
                  }
                ]
            }
        }
    }