Hello there! I think there is an edge case with combineWith:'AND' where search results are produced incorrectly. It's easier to explain with example then in words, so please bare with me here.
Consider the following setup:
const index = new MiniSearch({
fields: ['text'],
processTerm(term) {
term = term.toLowerCase();
switch (term) {
case 'motorcycle':
return [term, 'scooter']
default:
return term
}
},
searchOptions: {
combineWith: 'AND',
processTerm(term) {
term = term.toLowerCase();
switch (term) {
case 'motorcycle':
return [term, 'bike']
default:
return term
}
}
}
})
index.add({ id: 1, text: 'yamaha motorcycle' });
index.add({ id: 2, text: 'yamaha car' });
If we specify combineWith:'AND'
// returns nothing
console.log(index.search('motorcycle', { prefix: true }));
// returns id:2
console.log(index.search('yamaha car', { prefix: true }));
If we specify combineWith:'OR'
// returns id:1
console.log(index.search('motorcycle', { prefix: true }));
// returns both id:1 and id:2
console.log(index.search('yamaha car', { prefix: true }));
However what I want to achieve is
// returns id:1
console.log(index.search('motorcycle', { prefix: true }));
// returns id:2
console.log(index.search('yamaha car', { prefix: true }));
From my perspective combineWith: 'AND' should be applied such that I get the result I am looking for. So it uses AND operator between tokens, but does not use AND operator between terms for the same token. Does it make any sense?
The example here is totally made up. My actual use case is transliteration, where conversion of terms isn't lossless (some letters could disappear) which results in the problem I've described here.
Hello there! I think there is an edge case with
combineWith:'AND'where search results are produced incorrectly. It's easier to explain with example then in words, so please bare with me here.Consider the following setup:
If we specify
combineWith:'AND'If we specify
combineWith:'OR'However what I want to achieve is
From my perspective
combineWith: 'AND'should be applied such that I get the result I am looking for. So it usesANDoperator between tokens, but does not useANDoperator between terms for the same token. Does it make any sense?The example here is totally made up. My actual use case is transliteration, where conversion of terms isn't lossless (some letters could disappear) which results in the problem I've described here.