首页 > 其他分享 >好用的字符串搜索库 - Fuse.js

好用的字符串搜索库 - Fuse.js

时间:2023-04-19 09:00:27浏览次数:45  
标签:匹配 Default true js will Fuse Type 好用 match

https://github.com/krisk/Fuse

 

Options

#Basic Options

#isCaseSensitive

  • Type: boolean
  • Default: false

Indicates whether comparisons should be case sensitive.

#includeScore

  • Type: boolean
  • Default: false

Whether the score should be included in the result set. A score of 0indicates a perfect match, while a score of 1 indicates a complete mismatch.
分数是否应包括在结果中。分数为0表示完全匹配,而分数为1表示完全不匹配。

#includeMatches

  • Type: boolean
  • Default: false

Whether the matches should be included in the result set. When true, each record in the result set will include the indices of the matched characters. These can consequently be used for highlighting purposes.
匹配的内容是否应该包括在结果中。当为真时,结果集中的每条记录都将包括匹配字符的索引。因此,这些可以用于突出显示的目的。

#minMatchCharLength

  • Type: number
  • Default: 1

Only the matches whose length exceeds this value will be returned. (For instance, if you want to ignore single character matches in the result, set it to 2).
只有长度超过这个值的匹配才会被返回。(例如,如果你想在结果中忽略单字符匹配,将其设置为2)。

#shouldSort

  • Type: boolean
  • Default: true

Whether to sort the result list, by score.
是否对结果列表进行排序,按分数排序。

#findAllMatches

  • Type: boolean
  • Default: false

When true, the matching function will continue to the end of a search pattern even if a perfect match has already been located in the string.

当为 "true "时,即使在字符串中已经找到了完美匹配,匹配功能也会继续到搜索模式的末端。

#keys

  • Type: Array
  • Default: []

List of keys that will be searched. This supports nested paths, weighted search, searching in arrays of strings and objects.
将被搜索的键的列表。这支持嵌套路径,加权搜索,在字符串和对象的数组中搜索。

#Fuzzy Matching Options

#location

  • Type: number
  • Default: 0

Determines approximately where in the text is the pattern expected to be found.
确定在文本中预期找到的模式的大约位置。

#threshold

  • Type: number
  • Default: 0.6

At what point does the match algorithm give up. A threshold of 0.0 requires a perfect match (of both letters and location), a threshold of 1.0 would match anything.
匹配算法在什么时候会放弃。0.0的阈值要求完全匹配(字母和位置),1.0的阈值将匹配任何东西。

#distance

  • Type: number
  • Default: 100

Determines how close the match must be to the fuzzy location (specified by location). An exact letter match which is distance characters away from the fuzzy location would score as a complete mismatch. A distance of 0 requires the match be at the exact location specified. A distance of 1000 would require a perfect match to be within 800 characters of the location to be found using a threshold of 0.8.
决定匹配必须与模糊位置(由位置指定)有多近。一个精确的字母匹配,如果离模糊位置有一定的距离,将被视为完全不匹配。如果距离为0,则需要在指定的确切位置进行匹配。如果距离为1000,则需要在800个字符内找到一个完全匹配的位置,使用0.8的阈值。

#ignoreLocation

  • Type: boolean
  • Default: false

When true, search will ignore location and distance, so it won't matter where in the string the pattern appears.
当为 "true "时,搜索将忽略位置和距离,所以图案出现在字符串的哪个位置并不重要。

TIP

The default options only search the first 60 characters. This should suffice if it is reasonably expected that the match is within this range. To modify this behavior, set the appropriate combination of locationthresholddistance (or ignoreLocation).
默认选项只搜索前60个字符。如果可以合理地预期匹配在这个范围内,这就足够了。要修改这种行为,请设置适当的位置、阈值、距离(或忽略位置)的组合。

To better understand how these options work together, read our Scoring Theory.

#Advanced Options  高级选项

#useExtendedSearch

  • Type: boolean
  • Default: false

When true, it enables the use of unix-like search commands. See example.
当为 "true "时,它可以启用类似unix的搜索命令。请看例子。

#getFn

  • Type: Function
  • Default: (obj: T, path: string | string[]) => string | string[]

The function to use to retrieve an object's value at the provided path. The default will also search nested paths.

用来检索对象在提供的路径上的值的函数。默认情况下,也会搜索嵌套的路径。

#sortFn

  • Type: Function
  • Default: (a, b) => number

The function to use to sort all the results. The default will sort by ascending relevance score, ascending index.
用来对所有结果进行排序的函数。默认情况下,将按相关性分数升序排序,指数升序排序。

#ignoreFieldNorm

  • Type: boolean
  • Default: false

When true, the calculation for the relevance score (used for sorting) will ignore the field-length norm.
当为真时,相关性分数的计算(用于排序)将忽略字段长度规范。

TIP

The only time it makes sense to set ignoreFieldNorm to true is when it does not matter how many terms there are, but only that the query term exists.

唯一将ignoreFieldNorm设置为 "true "有意义的是,当有多少个术语,而只是查询术语存在时,这并不重要。

#fieldNormWeight

  • Type: number
  • Default: 1

Determines how much the field-length norm affects scoring. A value of 0 is equivalent to ignoring the field-length norm. A value of 0.5 will greatly reduce the effect of field-length norm, while a value of 2.0 will greatly increase it.
决定字段长度规范对评分的影响程度。0的值相当于忽略了字段长度规范。0.5的值将大大降低场长规范的影响,而2.0的值将大大增加它。

标签:匹配,Default,true,js,will,Fuse,Type,好用,match
From: https://www.cnblogs.com/it-Ren/p/17332009.html

相关文章

  • Nodejs的安装与使用
    Nodejs的安装与使用转载请注明来源:http://www.eword.name/Author:ewordEmail:[email protected]一、Centos安装Nodejs1.1、资料准备1.1.1、下载安装包从官网下下载最新的nodejshttps://nodejs.org/en/download/下载#cdopt/#wgethttps://nodejs.org/dist/v10.20.0......
  • Nodejs的安装与使用
    Nodejs的安装与使用转载请注明来源:http://www.eword.name/Author:ewordEmail:[email protected]一、Centos安装Nodejs1.1、资料准备1.1.1、下载安装包从官网下下载最新的nodejshttps://nodejs.org/en/download/下载#cdopt/#wgethttps://nodejs.org/dist/v10.20.0......
  • 在线客服系统访客发送录音功能,在elementui中使用js-audio-recorder实现录音功能,然后上
    访客在聊天界面中可以发送语音,其实就是录音以后,调用上传接口,把录音文件发送给客服。 点击麦克图标以后,展示出一个elementui的dialog弹窗,里面展示四个功能按钮。分别是,开始录音,结束录音,取消录音,发送录音。基本流程就是点开始,然后点结束,再点发送。下面是聊天界面中的dialog弹窗......
  • js-深拷贝和浅拷贝
    浅拷贝:有两种方式,一种是把一个对象里面的所有的属性值和方法都复制给另一个对象,另一种是直接把一个对象赋给另一个对象,使得两个都指向同一个对象。深拷贝:把一个对象的属性和方法一个个找出来,在另一个对象中开辟对应的空间,一个个存储到另一个对象中。两者就在于,浅拷贝只是简单的......
  • It's all but a dream(JSOI2023 追忆)
    联赛220,队线265,哈哈。day0下午先去了华山,进行了一个喝茶???看着联赛270+的队爷们,感觉人类的悲欢并不相通。晚上试机,由于并不会用Vim,计划sublime写+code::blocks调。先配了code::blocks,然后发现并不能运行???查了下发现是xterm没装,尝试自己装一下,然后发现密码并不是123......
  • Downie 4 4.6.14 for Mac 最新最好用的视频下载工具
    DownieforMac Downie是Mac下一个简单的下载管理器,可以让您快速将不同的视频网站上的视频下载并保存到电脑磁盘里然后使用您的默认媒体播放器观看它们。  Downie4最新版下载Downie4forMacDownie4forMac软件特点支持许多站点-当前支持1000多个不同的站点(包括You......
  • Node.js入门学习笔记
    NodeJs是js的运行时,意味着可以在浏览器外运行js。可以使用nodejs来构建服务器端应用、CLI应用、WebAPI,甚至用electron构建桌面端应用。使用nvm来管理node版本。在终端输入node进入REPL环境,可以测试和执行代码,mac系统使用control+d退出REPL环境。执行某个js文件:nodexxx.js......
  • JS巩固
    https://www.bilibili.com/video/BV1sN411974w?p=3&spm_id_from=pageDriver&vd_source=b16c9d62fc80d4f0761a959bb9fdb870P3 ......
  • js知识点
    目录js知识点js数据类型数组forEach()补充三元运算函数函数的全局变量和局部变量内置对象和方法自定义对象Date对象Date对象的方法JSON对象EegExp对象MAth对象BOM和DOMBOM弹出框计时相关DOM标签查找间接查找节点操作属性节点获取值操作class的操作事件绑定方法js知识点jsjs的......
  • 分享一个很好用的代理转发工具:rinetd
    rinetd介绍:安装与使用:https://zhuanlan.zhihu.com/p/530875131注意事项:1、如果发现配置中的端口在进程中没找到,那就是配置填写错误导致的,笔者就遇到过,端口写个了66666,结果就翻车了,切记按照规则来操作使用场景1、需要测试网络中断的场景,模拟网络异常2、测试负载均衡,等等......