elasticsearch - 弹性搜索查询无法运行
问题描述
我对弹性搜索很陌生,想在匹配条件时为特定字段的所有值编写查询,我尝试构建以下查询,基本上它来自 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": []
}
}'
我收到以下错误,我相信这与格式化查询有关
{
"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
}
我在这里做错了什么?
解决方案
弹性搜索抱怨您的 json 字符串末尾缺少花括号。您可以使用许多(哦,这么多)在线 json 验证器中的任何一个来验证您的 json 架构,例如https://jsonlint.com/
推荐阅读
- visual-studio - Javascript语言服务未下载成功
- python - 将 JSON 文件中的数据转换为 Python dict
- go - Golang - Gob over TCP 的不稳定性
- azure - Azure devops 管道/VS 模板/dockerfile 中的错误?
- html - 无法使用 iOS 在 Moodle 中查看 GDrive
- java - Javafx 将声音作为对象播放
- java - 升级Redis服务器时无法获取Redis Lock,进程卡住
- arrays - 返回 Json 数组的最佳方法是什么?
- javascript - 将对象值动态分配给变量 javascript
- javascript - 每个意图的 TensorFlow 预测都是相同的