Closed spike-rabbit closed 3 years ago
This is by design:
The
$or
operator uses short-circuit evaluation (i.e, if the first expression evaluates totrue
, Fuse.js will not evaluate the remaining expressions).
For example, in your second query, the first OR condition is { "name": "IN_PROGRESS"}
, which is still finding a match for the first item in the list:
{
"id": 132,
"name": "serious request",
"status": "IN_PROGRESS",
"client": {
"name": "serious-client", // <-- still finding a match for this
}
}
Since the match's score is good enough for it to be included, all subsequent conditions in the $or
query are skipped.
If you want more restrictive searching, you could decrease the threshold
and change minMatchCharLength
😄
I guess there's a question there on whether it should continue with all subsequent conditions and pick the one with the best score, as opposed to short-circuiting.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
@krisk
I guess there's a question there on whether it should continue with all subsequent conditions and pick the one with the best score, as opposed to short-circuiting.
Surely this should be an option? The short circuit behaviour is not always desirable, and allowing all conditions to evaluate and give a proper score would help make the sorted results significantly more relevant.
Describe the bug
When using object queries, the order of keys seems to matter. I guess this is not intended.
Version
6.4.3
Is this a regression?
I don't know. Previously I was not using the object search
🔬Minimal Reproduction
just run this script https://gist.github.com/spike-rabbit/389e2b2cfdea1d706dac38a899748de1
Additional context
As mentioned in the gist, lowering the threshold seems to bypass the problem.