如何在Couchbase中使用LIKE n1ql查询?

问题描述 投票:1回答:1

我想代表一个我还不了解的问题。我给你看下面的例子。这是我的文件

doc 1 : {"type":"81"}
doc 2 : {"type":"81_"}
doc 3 : {"type":"8"}
doc 4 : {"type":"8_"}
doc 5 : {"type":"13"}

现在,我想使用n1ql查询以获取匹配类型,例如“ 8 _%” 8_应该是字符串前缀的文档

@Query("#{#n1ql.selectEntity} where code like "8_%" ") 
**or**
@Query("#{#n1ql.selectEntity} where code like (concat(8,_,'%')) ")

他们俩都不能正确回答我是谁。响应中应该只有一个文档是doc 4:{“ type”:“ 8 _”}。但是这个回应如下文件。

 doc 1 : {"type":"81"}
 doc 2 : {"type":"81_"}
 doc 3 : {"type":"8"}
 doc 4 : {"type":"8_"}

您能在遇到情况时帮助我吗?谢谢高级。我正在使用Couchbase 3.1.8。对不起,我的英语不好[]

我想代表一个我还不了解的问题。我给你看下面的例子。这是我的文档doc 1:{“ type”:“ 81”} doc 2:{“ type”:“ 81_”} doc 3:{“ type”:“ 8”} doc 4:{“ type”: 。

spring-boot couchbase n1ql
1个回答
1
投票

以下查询返回正确的结果

© www.soinside.com 2019 - 2024. All rights reserved.