Elasticsearch嵌套排序 - 用于排序文档和嵌套的对象之间的失配

问题描述 投票:0回答:1

我一直在发展与AWS Elasticsearch一个新的搜索API作为后端(6.2版本)。

现在,我想支持的API“排序”选项。

我的映射如下(不包括不相关的领域):

{
  "properties": {
    "id": {
      "type": "text",
      "fields": {
        "raw": {
          "type":  "keyword"
        }
      }
    },
    "description": {
      "type": "text"
    },
    "materialDefinitionProperties": {
      "type": "nested",
      "properties": {
        "id": {
          "type": "text",
          "fields": {
            "raw": {
              "type":  "keyword"
            }
          },
          "analyzer": "case_sensitive_analyzer"
        },
        "value" : {
          "type": "nested",
          "properties": {
            "valueString": {
              "type": "text",
              "fields": {
                "raw": {
                  "type":  "keyword"
                }
              }
            }
          }
        }
      }
    }
  }
}

我试图让用户排序属性值(路径:materialDefinitionProperties.value.valueLong.raw)。

请注意,这是内部的2级嵌套对象(materialDefinitionProperties和materialDefinitionProperties.value嵌套对象)。

要通过的ID为“料号”属性的值对结果进行排序,我对排序的要求是:

{
    "fieldName": "materialDefinitionProperties.value.valueString.raw",
    "nestedSort": {
        "path": "materialDefinitionProperties",
        "filter": {
            "fieldName": "materialDefinitionProperties.id",
            "value": "PART NUMBER",
            "slop": 0,
            "boost": 1
        },
        "nestedSort": {
            "path": "materialDefinitionProperties.value"
        }
    },
    "order": "ASC"
}

然而,当我检查了回应,“排序”字段不匹配文档的属性值:

{
    "_index": "material-definition-index-v2",
    "_type": "default",
    "_id": "development_LITL4ZCNE",
    "_source": {
        "id": "LITL4ZCNE",
        "description": [
            "CPU, Intel, Cascade Lake, 8259CL, 24C, 210W, B1 Prod"
        ]
        "materialDefinitionProperties": [
            {
                "id": "PART NUMBER",
                "description": [],
                "value": [
                    {
                        "valueString": "202-001193-001",
                        "isOriginal": true
                    }
                ]
            }
        ]
    },
    "sort": [
        "100-000018"
    ]
},

该文件的零件编号属性是“202-001193-001”,“排序”字段说“100-000018”,这是另一个文档的部件号。

看来,有用于排序的主文档和嵌套对象之间的不匹配。

这个请求行之有效的时候这里只有集群中的文档数量很少。但是,一旦我回填集群〜1万元的记录,将出现症状。我也尝试创建一个新的ES集群,但结果是一样的。

其他非嵌套属性进行分类运作良好。

我误解嵌套对象的概念,或滥用嵌套排序功能?

任何想法表示赞赏!

java amazon-web-services elasticsearch aws-elasticsearch
1个回答
0
投票

这是Elasticsearch的错误。升级到6.4.0固定的问题。

问题追踪:https://github.com/elastic/elasticsearch/pull/32204

版本说明:https://www.elastic.co/guide/en/elasticsearch/reference/current/release-notes-6.4.0.html

© www.soinside.com 2019 - 2024. All rights reserved.