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



例如,我正在搜索用户"John Doe",但希望只输入"John"或"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"并获取用户,但无法使用单词的一部分来查找用户。

提前谢谢。

您需要

创建一个视图,并通过它自己发出文本中的每个单词以及文档的 de id 等引用。

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

我猜你在设计/_design/lucene/by_user_name 上发出一个名为 user_name 的字段,而不是尝试使用 for 和拆分。 通过 for 循环发出,数组中按空格(" "(拆分的每个元素都会生成,仅此而已

相关内容

最新更新