如何通过使用嵌套 属性 为创建的 elasticsearch 索引解决根映射定义具有不受支持的参数?

How can I solve Root mapping definition has unsupported parameters by using nested property for created elasticsearch index?

如何使用嵌套 属性 创建索引来创建映射结构?我在下面收到错误。 url 产生以下结果: http://xxx:9200/usereventsreduced-2020/event/_search?pretty=true

UrlQueryString 是嵌套的!我们需要描述它是嵌套的。

{
  "took": 42,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 7108,
    "max_score": 7.4923043,
    "hits": [
      {
        "_index": "usereventsreduced-2020",
        "_type": "event",
        "_id": "omHM3G8BiazbIYmiMj35",
        "_score": 7.4923043,
        "_source": {
          "UserId": "",
          "SessionId": "",
          "LogLevel": "Error",
          "CorrelationId": "d49ad78d-1f38-4fed-ae47-9d6768402212",
          "UrlMethod": "GET",
          "Data": "",
          "UrlQueryString": {
            "smId": "df178847-c8e2-4434-b779-eeb248b9bebb"
          },
          "UrlPath": "/PaymentResultCommon",
          "LogSource": "B2EUi",
          "LogDate": "2020-01-25T13:01:14.4634937Z",
          "Environment": "Production-K8S"
        }
      },
      {
        "_index": "usereventsreduced-2020",
        "_type": "event",
        "_id": "1V9W3G8BiazbIYmi4uwD",
        "_score": 7.4923043,
        "_source": {
          "UserId": "",
          "SessionId": "",
          "LogLevel": "Error",
          "CorrelationId": "959d767d-cd66-4878-a5ca-e8e887aeec95",
          "UrlMethod": "GET",
          "Data": "",
          "UrlQueryString": {
            "b": "ce5cb7ed-280d-419a-9906-25004b799750",
            "t": "e05879ec-668b-41dc-9b77-09072ab62ef4"
          },
          "UrlPath": "/PaymentCallBack",
          "LogSource": "B2EUi",
          "LogDate": "2020-01-25T10:53:39.2500748Z",
          "Environment": "Production-K8S"
        }
      },
      {
        "_index": "usereventsreduced-2020",
        "_type": "event",
        "_id": "_YDh528BiazbIYmiU_nH",
        "_score": 7.4923043,
        "_source": {
          "UserId": "",
          "SessionId": "",
          "LogLevel": "Error",
          "CorrelationId": "6417519f-6f61-496d-8eba-3dd32b5c1ddf",
          "UrlMethod": "GET",
          "Data": "",
          "UrlQueryString": {
            "b": "eef54432-df76-40f4-9a7b-aa447b20eb27",
            "t": "97d3734c-203f-48a4-ac9f-77d575528121"
          },
          "UrlPath": "/PaymentCallBack",
          "LogSource": "B2EUi",
          "LogDate": "2020-01-27T16:40:51.0060448Z",
          "Environment": "Production-K8S"
        }
      }
    ]
  }
}

但是下面的代码不起作用,因为我必须用嵌套对象描述我的 paping。 UrlQueryString 是嵌套的。

{
    "query": {
        "nested" : {
            "path" : "UrlQueryString",
            "query" : {
                "bool" : {
                    "must" : [
                    { "match" : {"UrlQueryString.parameter" : "grand-urfa-hotel"} }
                    ]
                }
            }
        }
    }
}

我的映射代码:

PUT /usereventsreduced-*/_mapping/event
{
    "mappings" : {
        "properties" : {
            "UrlQueryString" : {
                "type" : "nested"
            }
        }
    }
}

结果:

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Root mapping definition has unsupported parameters:  [mappings : {properties={UrlQueryString={type=nested}}}]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Root mapping definition has unsupported parameters:  [mappings : {properties={UrlQueryString={type=nested}}}]"
  },
  "status": 400
}

注意映射规范的外观:https://prnt.sc/qyhwpu

基于此,您可以使用:

DELETE usereventsreduced
PUT /usereventsreduced-*/
{
  "mappings": {
    "event": {
      "properties": {
        "UrlQueryString": {
          "type": "nested"
        }
      }
    }
  }
}

PUT /usereventsreduced-*/event/_mapping
{
  "properties": {
    "UrlQueryString": {
      "type": "nested"
    }
  }
}