Find similar names using Couchbase server 3.0 and port 8092

旧城冷巷雨未停 提交于 2019-12-11 16:29:57

问题


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


回答1:


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).



来源:https://stackoverflow.com/questions/31268624/find-similar-names-using-couchbase-server-3-0-and-port-8092

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!