Cloudant 搜索字段在没有位置数据的情况下被索引;不能 运行 短语查询
Cloudant Search field was indexed without position data; cannot run PhraseQuery
我有以下 Cloudant 搜索索引
"indexes": {
"search-cloud": {
"analyzer": "standard",
"index": "function(doc) {
if (doc.name) {
index("keywords", doc.name);
index("name", doc.name, {
"store": true,
"index": false
});
}
if (doc.type === "file" && doc.keywords) {
index("keywords", doc.keywords);
}
}"
}
}
由于某种原因,当我搜索特定短语时,出现错误:
Search failed: field "keywords" was indexed without position data; cannot run PhraseQuery (term=FIRSTWORD)
因此,如果我搜索 FIRSTWORD SECONDWORD,我似乎在第一个词上遇到了错误。
注意:并不是我搜索的每个词组都会出现这种情况。
有谁知道为什么会这样?
doc.name
和 doc.keywords
只是字符串。
doc.name
通常类似于 "2004/04/14 John Doe 1234 Document Folder"
doc.keywords
通常是随机的,例如 "testing this again"
我之所以将名称和关键字存储在关键字索引下,是因为我希望任何人都能够通过键入字符串值来搜索关键字或名称。如果这不是最佳做法,请告诉我。
可能的问题是,您的某些文档包含带有字符串值的 keywords
字段,而其他文档包含具有不同类型(可能是数组)的 keywords
字段。我相信这种情况会导致您收到错误。您能否仔细检查 keywords
字段的所有值实际上都是字符串?
我有以下 Cloudant 搜索索引
"indexes": {
"search-cloud": {
"analyzer": "standard",
"index": "function(doc) {
if (doc.name) {
index("keywords", doc.name);
index("name", doc.name, {
"store": true,
"index": false
});
}
if (doc.type === "file" && doc.keywords) {
index("keywords", doc.keywords);
}
}"
}
}
由于某种原因,当我搜索特定短语时,出现错误:
Search failed: field "keywords" was indexed without position data; cannot run PhraseQuery (term=FIRSTWORD)
因此,如果我搜索 FIRSTWORD SECONDWORD,我似乎在第一个词上遇到了错误。
注意:并不是我搜索的每个词组都会出现这种情况。
有谁知道为什么会这样?
doc.name
和 doc.keywords
只是字符串。
doc.name
通常类似于 "2004/04/14 John Doe 1234 Document Folder"
doc.keywords
通常是随机的,例如 "testing this again"
我之所以将名称和关键字存储在关键字索引下,是因为我希望任何人都能够通过键入字符串值来搜索关键字或名称。如果这不是最佳做法,请告诉我。
可能的问题是,您的某些文档包含带有字符串值的 keywords
字段,而其他文档包含具有不同类型(可能是数组)的 keywords
字段。我相信这种情况会导致您收到错误。您能否仔细检查 keywords
字段的所有值实际上都是字符串?