olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.87k stars 546 forks source link

Scoring strange when searching for 2x4 #508

Closed PTC-JoshuaMatthews closed 2 years ago

PTC-JoshuaMatthews commented 2 years ago

Using a query like

`
var results = index.query(function (q) {

        q.term(lunr.tokenizer(currentFilter), { boost: 100, usePipeline: true, fields: fields })

        q.term(lunr.tokenizer(currentFilter), { boost: 10, usePipeline: false, fields: fields, wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING })

        q.term(lunr.tokenizer(currentFilter), { boost: 5, editDistance: 1, fields: fields })

        q.term(lunr.tokenizer(currentFilter), { boost: 1, editDistance: 2, fields: fields })

      })

`

When I search for 2x4 it treats 2 and 4 as two separate tokens and ends up scoring results that contains lots of 2's and 4's higher than results that directly contain 2x4

Is there anyway to make it parse 2x4 as a single search term?