0

I am new to backgrid.js and I am using filter as an extension function for my web app. I am quite confused about LunrFilter. As the code defines in this page, it has the parameter { field : 10 }. May I know what and how does field name and boost value affect the filtration of collection?

Also, is it possible for Backgrid.filter to filter collections by precedence?

For example, I have the following data:

Record #1 - fname : Adam; lname : Smith
Record #2 - fname : Luke; lname : Adam
Record #3 - fname : John; lname : Adam

I would like to take precedence of lname over fname on filtering. If I key in "Adam" on search bar - table must display Records #2 and #3 first, and #1 last.

4

1 回答 1

0

从文档

可以传递一个可选的 boost 参数来影响该字段中的令牌在搜索结果中的排名,默认情况下 boost 值为 1。

我怀疑它是用来对搜索结果进行排名的。这些字段实际上应该是一个 json 对象。其中每个名称都是字段名称。每个值都是提升值。

fields:{
    Name:10,
    Field2:1,
    Field3:1,
}

默认情况下,lunrjs 中的 boost 为 1,并且是可选的。但我想在这种情况下你必须为每个字段设置提升。

于 2015-04-17T15:40:23.137 回答