简体   繁体   English

弹性搜索查询无法运行

[英]Elastic-search query failing to run

I'm pretty new to elastic search and would like to write a query for all of the values a specific field when it matches a condition, I tried building the below query, basically its from Kibana, i copied the request body and tried running with ES node. 我是弹性搜索的新手,想在条件匹配时为特定字段的所有值编写查询,我尝试构建下面的查询,基本上是从Kibana来的,我复制了请求主体并尝试运行ES节点。

curl -XGET "http://localhost:9200/test_index/_search?pretty" -H 'Content-Type: application/json' -d'
 {
  "version": true,
  "size": 500,
  "sort": [
    {
      "actual_start": {
        "order": "desc",
        "unmapped_type": "boolean"
      }
    }
  ],
  "_source": {
    "excludes": []
  },
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "actual_start",
        "interval": "5m",
        "time_zone": "Asia/Kolkata",
        "min_doc_count": 1
      }
    }
  },
  "stored_fields": [
    "*"
  ],
  "script_fields": {},
  "docvalue_fields": [
    {
      "field": "Updated",
      "format": "date_time"
    },
    {
      "field": "actual_end",
      "format": "date_time"
    },
    {
      "field": "actual_start",
      "format": "date_time"
    },
    {
      "field": "created_on",
      "format": "date_time"
    },
    {
      "field": "planned_start",
      "format": "date_time"
    }
  ],
  "query": {
    "bool": {
      "must": [
        {
          "match_all": {}
        },
        {
          "exists": {
            "field": "Number"
          }
        },
        {
          "match_phrase": {
            "change_manager_group": {
              "query": "Change Managers - 2"
            }
          }
        },
        {
          "range": {
            "actual_start": {
              "gte": 1556028682454,
              "lte": 1556043082454,
              "format": "epoch_millis"
            }
          }
        }
      ],
      "filter": [],
      "should": [],
      "must_not": []
    }
  }'

I am getting the below error, I believe this is related to formatting the query 我收到以下错误,我相信这与格式化查询有关

{
  "error" : {
    "root_cause" : [
      {
        "type" : "json_e_o_f_exception",
        "reason" : "Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@177d880d; line: 2, column: 1])\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@177d880d; line: 85, column: 1448]"
      }
    ],
    "type" : "json_e_o_f_exception",
    "reason" : "Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@177d880d; line: 2, column: 1])\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@177d880d; line: 85, column: 1448]"
  },
  "status" : 500
}

What i am doing wrong here? 我在这里做错了什么?

Elastic search is complaining about a missing curly brace at the end of your json string. 弹性搜索抱怨json字符串末尾缺少花括号。 You can verify your json schema using any of the many (oh so many) online json validators like https://jsonlint.com/ 您可以使用https://jsonlint.com/等众多在线JSON验证器中的任何一种来验证JSON模式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM