Forgot password?
 Create new account
View 100|Reply 0

lunr搜索

[Copy link]

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2023-7-29 11:23:29 |Read mode
lunrDemo页面有很多列表项目,输入关键词,就可以筛选出包含关键词的项目。
  1. <script src="https://unpkg.com/lunr/lunr.js"></script>
Copy the Code

首先建立索引,用JS执行搜索。
多关键词:
  1. idx.search('foo bar')
Copy the Code
正则:
  1. idx.search('foo*')
Copy the Code
字段:
  1. idx.search('title:foo')
Copy the Code
权重:
  1. idx.search('foo^10 bar^5 baz')
Copy the Code
模糊:
  1. idx.search('foo~1')
Copy the Code
布尔代数:
  1. idx.search("+foo bar -baz")
Copy the Code

手机版Mobile version|Leisure Math Forum

2025-4-20 22:25 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list