gpt4 book ai didi

node.js - 带有 url 数组的 Elasticsearch 术语

转载 作者:行者123 更新时间:2023-12-03 01:29:46 25 4
gpt4 key购买 nike

我使用的是 Elasticsearch 5.5,下面是 Elasticsearch 的索引

[
{
"_index" : "corpindex-qa",
"_type" : "corpdocs-qa",
"_id" : "5cb468fd35b9db6f2235e4c4",
"_score" : 1.0,
"_source" : {
"Edition" : {
"Values" : {
"title" : "new featured parallex"
}
},
"url" : "/demo-inline-component-capability/demo-of-featured-parallex",
"year" : 2019,
"author" : "",
"docdef" : "new-featured-parallex-reference-1"
}
},
{
"_index" : "corpindex-qa",
"_type" : "corpdocs-qa",
"_id" : "5ccfe1dd6948151485158661",
"_score" : 1.0,
"_source" : {
"Edition" : {
"Values" : {
"title" : "demo of event careers",
"description" : "careers"

}
},
"url" : "/demo-inline-component-capability/demo-of-event-card",
"year" : 2019,
"author" : "",
"docdef" : "inline-event-card"
}
}]

尝试通过在带有 Elasticsearch 客户端模块的 nodejs 上使用带有术语的查询来获取文档。
client.search({
index: searchIndex,
type: searchType
, body: {
query: {
terms: {
"url": ["/demo-inline-component-capability/demo-of-featured-parallex","/demo-inline-component-capability/demo-of-event-card"]
}
}
}
});

在执行上述操作时获得零文档。
{"took":0,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

这是映射细节,它取自 elasticsaerch
{
corpindex-qa: {
aliases: { },
mappings: {
corpdocs-qa: {
properties: {
url: {
type: "text",
fields: {
keyword: {
type: "keyword",
ignore_above: 256
}
}
},
year: {
type: "long"
}
}
}
},
settings: {
index: {
creation_date: "1559900006341",
number_of_shards: "5",
number_of_replicas: "1",
uuid: "xL6PICFARZq6zMZBpm-75A",
version: {
created: "5050399"
},
provided_name: "corpindex-qa"
}
}
}
}

请分享您对我有帮助的想法。

最佳答案

由于您试图精确匹配 url使用 url.keyword而不是 url .将您的查询更新为以下内容:

client.search({
index: searchIndex,
type: searchType
, body: {
query: {
terms: {
"url.keyword": ["/demo-inline-component-capability/demo-of-featured-parallex","/demo-inline-component-capability/demo-of-event-card"]
}
}
}
});

关于node.js - 带有 url 数组的 Elasticsearch 术语,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56537700/

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