如何使用couchdb-lucene查询单词的一部分?

时间:2016-02-15 12:19:33

标签: jquery search lucene request couchdb

例如,我正在搜索用户" John Doe"但是希望只输入约翰"或" Doe"为了得到用户。

这是我目前提出的要求:

request('http://' + globals.serverAddress + ':' + globals.lucenePort + '/_fti/local/testdatabase/_design/lucene/by_user_name?q=' + req.query.searchString + '&include_docs=true', function(error, requestResponse, body) {

// Sending the data here from the API to the app

});

目前,我能够搜索John Doe"并获取用户,但不能使用该部分单词来查找用户。

提前致谢。

1 个答案:

答案 0 :(得分:0)

您需要创建一个视图并将文本中的每个单词自发地发送到文档的de id之类的引用。

这将创建一个可以查询的巨大视图

我猜测你在design / _design / lucene / by_user_name上发出一个名为user_name的字段,而不是尝试使用for和split。通过for循环发出,通过空格(“”)分割的数组的每个元素都将生成,就是它