使用Couchbase服务器3.0和端口8092查找相似的名称 [英] Find similar names using Couchbase server 3.0 and port 8092

查看:36
本文介绍了使用Couchbase服务器3.0和端口8092查找相似的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Couchbase服务器找到类似的位置名称.我创建了如下索引

 功能(文档,元数据){发出(doc.loc_name,doc);} 

这就是我查询数据的方式

  http://IP地址:8092/dev-locations/_design/dev_test_view/_view/searchByLocationName?full_set = true& inclusive_end = true& stale = false& connection_timeout = 60000& key =%22Joh%22 

但这仅在找到完全匹配的情况下才会返回.我正在寻找的是当我发送密钥 joh 时,它应该返回 johenaskirchen johenasberg (与我们在MySQL中的LIKE相同)

任何帮助将不胜感激.

注意:我已经尝试过N1QL,我正在寻找在没有N1QL的情况下实现此目的的方法

解决方案

key 参数完全匹配.您想要的是 startKey endKey 的组合:

 ?startkey =%22joh%22& endkey =%22joh \ uefff%22 

\ uefff 是一个技巧,此unicode字符可以看作是最大字符",因此可以确保在 johzzzzzz 之类的键下仍可以考虑 joh \ uefff 的上限(包括 endkey ).

I want to find the similar location names using couchbase server. i created an index as follows

function (doc, meta) {
  emit(doc.loc_name, doc);
}

this is how i query data

http://IP Address:8092/dev-locations/_design/dev_test_view/_view/searchByLocationName?full_set=true&inclusive_end=true&stale=false&connection_timeout=60000&key=%22Joh%22

But this will return only if the exact match found. What i am looking for is when i send the key joh, it should return johenaskirchen and johenasberg (same as our LIKE in MySQL)

Any help will be highly appreciated.

Note : I already tried N1QL and i am looking for ways to implement this without N1QL

解决方案

the key parameter is an exact match. What you want is a combination of startKey and endKey:

?startkey=%22joh%22&endkey=%22joh\uefff%22

The \uefff is a trick, this unicode character can be seen as "the biggest character" so it ensures that a key like johzzzzzz will still be considered under the upper bound of joh\uefff (endkey is inclusive).

这篇关于使用Couchbase服务器3.0和端口8092查找相似的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆