提问者:小点点

这个沙发基础索引有什么问题?


我创建了这个couchbase索引

CREATE INDEX `idx_additionalOrderCode` ON 
`order`(ALL ARRAY s.`value` FOR s IN additionalOrderCode WHEN s.`typeCode`= "MYCODE" END)
WHERE _class = "com.entrprise.OrderEntity" 

基于本页中的示例

https://docs . couch base . com/server/6.0/n1ql/n1ql-language-reference/indexing-arrays . html

但是当我用这个选择查询查询这个索引时:

SELECT * FROM `order` 
WHERE `_class` = "com.entrprise.OrderEntity" 
AND ANY s IN additionalOrderCode SATISFIES ( s.`value` = "130047777" ) and (s.typeCode = "MYCODE" ) END

我得到了错误

 "msg": "No index available on keyspace order that matches your query. Use CREATE INDEX or CREATE PRIMARY INDEX to create an index, or check that your expected index is online."

没有主索引支持查询,我希望我的所有查询都由辅助索引支持。

我使用的是企业版6.0.0内部版本1693

感谢您的帮助


共1个答案

匿名用户

用这个索引解决了它(我只删除了不同和数组之间的ALL)

CREATE INDEX `idx_additionalOrderCode` ON `order`
 (distinct (array (aoc.`value`) for `aoc` in `additionalOrderCode` WHEN aoc.`typeCode`= "WLEC"  END), orderTypeCode)
 WHERE (`_class` = "com.entreprise.OrderEntity")