javascript中是否有类似于Apache Solr全文搜索功能的方法来搜索数组并根据相关性返回结果?
示例:
var testData = [
'101',
'102C',
'103B',
'A',
'BD',
'AB',
'A102B',
'A1',
];
//if search Text is 102
var searchText = "102";
// results would be 102C, A102B
//if search Text is 102B
var searchText = "102B";
// result would be A102B, 102C
//if search Text is A
var searchText = "A";
// result would be A, A1, AB, A102
相关问题:stackoverflow.com/questions/5324798/
使用JavaScript处理此问题的最佳方法是什么?
您似乎正在寻找基于相关性返回结果的模糊搜索功能。看看Fuse.js,它在JavaScript中提供了类似Solr的数组和对象搜索。
http://fusejs.io