简体   繁体   English

Elasticsearch查询中的排除给出了无法解析搜索源的信息。 预期的字段名称,但获得了[START_OBJECT]

[英]Exclude in elasticsearch query gives failed to parse search source. expected field name but got [START_OBJECT]

I have following query, which 1. get all data with logtype error. 我有以下查询,该查询1.获取所有具有logtype错误的数据。 2. exclude all data in which there is error occured in logmessage fields. 2.排除logmessage字段中error occured所有数据。

curl -s -XGET 'localhost:9200/index_name/type/_search?pretty=true&size=10' -d '
{
    "query": {
        "match" : {
            "logtype" : "error"
        },
        "should": {
            "bool": {
               "must_not": {
                  "match": {
                     "logMessage": "*error occured*"
                  }
               }
            }
         }
    }
}
'

But the above command gives: 但是上面的命令给出:

 {
    "error": {
        "root_cause": [{
            "type": "parse_exception",
            "reason": "failed to parse search source. expected field name but got [START_OBJECT]"
        }],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [{
            "shard": 0,
            "index": "indexname",
            "node": "HxII3rajS4KP5dkP-ZvPSw",
            "reason": {
                "type": "parse_exception",
                "reason": "failed to parse search source. expected field name but got [START_OBJECT]"
            }
        }]
    },
    "status": 400
 }

How can it be solved? 如何解决?

Try this: 尝试这个:

curl -s -XGET 'localhost:9200/index_name/type/_search?pretty=true&size=10' -d '{
  "query": {
    "bool": {
      "must": {
        "match": {
          "logtype": "error"
        }
      },
      "must_not": {
         "match": {
           "logMessage": "*error occured*"
         }
      }
    }
  }
}'

暂无
暂无

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

相关问题 Elasticsearch 查询问题 - [范围] 格式错误的查询,预期为 [END_OBJECT],但发现 [FIELD_NAME] - Problem with Elasticsearch query - [range] malformed query, expected [END_OBJECT] but found [FIELD_NAME] 有什么方法可以使用curl查询多个文档以从_source提取字段值来查询elasticsearch吗? - Is there any way to query elasticsearch using curl for multiple documents to extract field values from _source? Elasticsearch长查询无法搜索 - Elasticsearch long query fails to search 范围查询不支持Elasticsearch字段 - Elasticsearch field not supported in range query 仅从 elasticsearch 查询返回 _source 数据 - return only _source data from elasticsearch query Elasticsearch使用搜索查询删除结果 - Elasticsearch Use Search Query for Deleting the results Elasticsearch Search Query using curl and subprocess: Illegal Argument Exception - Elasticsearch Search Query using curl and subprocess: Illegal Argument Exception 如何将 ElasticSearch 多匹配搜索查询从 cURL 转换为 JAVA? - How to translate an ElasticSearch multimatch search query from cURL into JAVA? 如何在Elasticsearch中更新字段的现有数据类型? (“没有在字段[名称]上声明类型[文本]的处理程序”) - How to update existing datatype of a field in elasticsearch ? (“No handler for type [text] declared on field [Name]”) Elasticsearch查询以检索所有ID的特定类型的特定_source值 - Elasticsearch query to retrieve particular _source value for a particular type for all ID's
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM