gpt4 book ai didi

elasticsearch - 嵌套对象中多个字段上的聚合在 Elasticsearch 1.7x中不起作用?

转载 作者:行者123 更新时间:2023-12-02 23:02:04 28 4
gpt4 key购买 nike

在亚马逊索引中的映射如下所示。 书包含具有多字段“别名”的嵌套作者。 “alias”和“alias.raw”应为作者中的有效字段。

{
mappings: {
book: {
properties: {
title: {
type: "string",
fields: {
raw: {type: "string", index: "not_analyzed"}
}
},
authors: {
type: "nested",
properties: {
alias: {
type: "string",
fields: {
raw : {
type: "string",
index: "not_analyzed"
}
}
},
alias_raw: {
type: "string",
index: "not_analyzed"
}

}
}
}
}
}
}

样本数据:

{index:{_ id:“1”,_ type:“book”}}
{title:“为假人超赞”,页面:“100”,作者:[{firstName:“Apollo”,lastName:“Cabrera”,别名:“Mister Awesome”,alias_raw:“Mister Awesome”}},{firstName: “Mark”,lastName:“Twain”,别名:“Julius Caesar”,alias_raw:“Julius Caesar”}]}

{index:{_ id:“2”,_ type:“book”}}
{title:“了解女人”,页面:“100000”,作者:[{firstname:“Megyn”,lastName:“Kelly”,别名:“Wonder Woman”,alias_raw:“Wonder Woman”}},{firstName:“Donald “,lastName:”王牌“,别名:”独行侠“,alias_raw:”独行侠“}]}

{index:{_ id:“3”,_ type:“book”}}
{title:“Snap Chat”,页数:“30”,作者:[{firstname:“Hilary”,lastName:“Clinton”,别名:“Code Zero”,alias_raw:“Code Zero”}},{firstName:“Harry “,lastName:” Houdini“,别名:” Abra Cadabra“,alias_raw:” Abra Cadabra“}]}

我的聚合查询如下所示:
{
query: {
match_all: {}
},
aggs: {
authors: {
nested: {
path: "authors"
},
aggs: {
aliases: {
terms: {
field: "alias.raw"
}
}
}
}
}
}

当我执行聚合查询时,我根本没有任何聚合。如果我使用“alias_raw”(这是我添加的另一个单独的字段),则会按预期获得完整的别名...
"aggregations" : {
"authors" : {
"doc_count" : 6,
"aliases" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [ {
"key" : "Abra Cadabra",
"doc_count" : 1
}, {
"key" : "Code Zero",
"doc_count" : 1
}, {
"key" : "Julius Caesar",
"doc_count" : 1
}, {
"key" : "Lone Ranger",
"doc_count" : 1
}, {
"key" : "Mister Awesome",
"doc_count" : 1
}, {
"key" : "Wonder Woman",
"doc_count" : 1
} ]
}
}
}

是否有另一种方式可以聚集多个字段而到达“alias.raw”? 如果仅使用“别名”,则会获得经过分析,标记化,分析的小写字段。我想要未分析的原始别名。我真的不需要,也不需要多余的“alias_raw”字段。

提前致谢 :)

最佳答案

弄清楚了。您必须使用完整路径作为字段名称...

字段:“authors.alias.raw”


{
query: {
match_all: {}
},
aggs: {
authors: {
nested: {
path: "authors"
},
aggs: {
aliases: {
terms: {
field: "authors.alias.raw"
}
}
}
}
}
}

欠吧:)

关于elasticsearch - 嵌套对象中多个字段上的聚合在 Elasticsearch 1.7x中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32129152/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com