olivernn / lunr.js

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

Support for OR based queries #36

Closed Rameshv closed 11 years ago

Rameshv commented 11 years ago

HI, First of all, thanks @olivernn for your great work. Currently lunr search do AND queries for multiple terms. But the app i am working on requires OR queries. I am trying to integrate OR based queries to lunr. Its fairly straight forward returning the result set. By replacing the

var documentSet = documentSets.reduce(function (memo, set) {   
    return memo.intersect(set)
})

with

var documentSet = documentSets.reduce(function (memo, set) {   
    return memo.union(set)
})

in lunr.Index.prototype.search would do the trick. I have ran some tests and it seems ok. I have added few test cases too.

But my main concern is about the score calculation for OR queries because i am not very sure about how to test this specific case. If you think this is worth, have a look at it.

olivernn commented 11 years ago

Thanks for taking the time to put together this pull request. I'm going to close this as, whilst the functionality is definitely something that needs to be added I have a different idea of how to implement it. I'd be very interested in your input on that issue #37 though so please take a look.