cloudant 按多个值搜索索引
cloudant searching index by multiple values
Cloudant 正在返回错误消息:
{"error":"invalid_key","reason":"Invalid key use-index for this request."}
每当我尝试使用组合运算符“$or”查询索引时。
我的文档示例如下:
{
"_id": "28f240f1bcc2fbd9e1e5174af6905349",
"_rev": "1-fb9a9150acbecd105f1616aff88c26a8",
"type": "Feature",
"properties": {
"PageName": "A8",
"PageNumber": 1,
"Lat": 43.051523,
"Long": -71.498852
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-71.49978935969642,
43.0508382914137
],
[
-71.49978564033566,
43.052210148524
],
[
-71.49791499857444,
43.05220740550381
],
[
-71.49791875962663,
43.05083554852429
],
[
-71.49978935969642,
43.0508382914137
]
]
]
}
}
我创建的索引是为字段 "properties.PageName" 创建的,当我只查询一个文档时它工作正常,但是当我尝试多个文档时,我会收到引用的错误响应一开始。
如果有帮助,请拨打电话:
POSThttps://xyz.cloudant.com/db/_find
请求正文:
{
"selector": {
"$or": [
{ "properties.PageName": "A8" },
{ "properties.PageName": "M30" },
{ "properties.PageName": "AH30" }
]
},
"use-index": "pagename-index"
}
为了执行 $or
查询,您需要创建 text
(全文)索引,而不是 json
索引。例如,我刚刚创建了以下索引:
{
"index": {
"fields": [
{"name": "properties.PageName", "type": "string"}
]
},
"type": "text"
}
然后我能够执行以下查询:
{
"selector": {
"$or": [
{ "properties.PageName": "A8" },
{ "properties.PageName": "M30" },
{ "properties.PageName": "AH30" }
]
}
}
Cloudant 正在返回错误消息:
{"error":"invalid_key","reason":"Invalid key use-index for this request."}
每当我尝试使用组合运算符“$or”查询索引时。
我的文档示例如下:
{
"_id": "28f240f1bcc2fbd9e1e5174af6905349",
"_rev": "1-fb9a9150acbecd105f1616aff88c26a8",
"type": "Feature",
"properties": {
"PageName": "A8",
"PageNumber": 1,
"Lat": 43.051523,
"Long": -71.498852
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-71.49978935969642,
43.0508382914137
],
[
-71.49978564033566,
43.052210148524
],
[
-71.49791499857444,
43.05220740550381
],
[
-71.49791875962663,
43.05083554852429
],
[
-71.49978935969642,
43.0508382914137
]
]
]
}
}
我创建的索引是为字段 "properties.PageName" 创建的,当我只查询一个文档时它工作正常,但是当我尝试多个文档时,我会收到引用的错误响应一开始。
如果有帮助,请拨打电话: POSThttps://xyz.cloudant.com/db/_find
请求正文:
{
"selector": {
"$or": [
{ "properties.PageName": "A8" },
{ "properties.PageName": "M30" },
{ "properties.PageName": "AH30" }
]
},
"use-index": "pagename-index"
}
为了执行 $or
查询,您需要创建 text
(全文)索引,而不是 json
索引。例如,我刚刚创建了以下索引:
{
"index": {
"fields": [
{"name": "properties.PageName", "type": "string"}
]
},
"type": "text"
}
然后我能够执行以下查询:
{
"selector": {
"$or": [
{ "properties.PageName": "A8" },
{ "properties.PageName": "M30" },
{ "properties.PageName": "AH30" }
]
}
}