-
-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-fields search in documents is not working #264
Comments
same here |
same issue here. I had a quick look at the sources and I think the issue is: Lines 444 to 447 in 65b027c
when doing a multi-field search on a document flexsearch appears to call search on each index without setting But because that block is not being executed (I haven't checked my findings yet because I don't currently have a device nearby that I can use for a testing environment) If I'm right either |
Ok, finally got around to testing it and this fixes it for me: Lines 397 to 403 in 65b027c
This block could to be changed to include e.g.: query = query || options["query"]; |
The source of the issue is L481 in Line 481 in 65b027c
FixThis would be a fix targeting diff --git a/src/document.js b/src/document.js
index 25da47c..9df6471 100644
--- a/src/document.js
+++ b/src/document.js
@@ -558,7 +558,8 @@ Document.prototype.search = function(query, limit, options, _resolve){
if(!is_string(key)){
opt = key;
- key = key["field"];
+ key = opt["field"];
+ query = query || opt["query"];
}
if(promises){ |
ups, nevermind. my second fix doesn't work as intended because in the second iteration of the loop I guess it could be solved by either introducing a new variable or something like this: diff --git a/src/document.js b/src/document.js
index 25da47c..5fd44c5 100644
--- a/src/document.js
+++ b/src/document.js
@@ -563,7 +563,7 @@ Document.prototype.search = function(query, limit, options, _resolve){
if(promises){
- promises[i] = this.index[key].searchAsync(query, limit, opt || options);
+ promises[i] = this.index[key].searchAsync((opt && opt["query"]) || query, limit, opt || options);
// just collect and continue
@@ -577,7 +577,7 @@ Document.prototype.search = function(query, limit, options, _resolve){
// inherit options also when search? it is just for laziness, Object.assign() has a cost
- res = this.index[key].search(query, limit, opt || options);
+ res = this.index[key].search((opt && opt["query"]) || query, limit, opt || options);
}
len = res && res.length; but performance-wise both of these solutions might not be optimal. so for now I will stick to my first suggestion (to modify diff --git a/src/index.js b/src/index.js
index 782ee0e..797cda8 100644
--- a/src/index.js
+++ b/src/index.js
@@ -400,6 +400,7 @@ Index.prototype.search = function(query, limit, options){
offset = options["offset"] || 0;
context = options["context"];
suggest = SUPPORT_SUGGESTION && options["suggest"];
+ query = options["query"] || query;
}
if(query){ |
@theguy147 have you considered making a PR? |
@theguy147 when is the next release planned with the fix? |
@GanserITService he won't be able to tell you that since he's not a contributor, but a user. |
@micheljung @GanserITService Yes, as @micheljung said, I am not a contributor in this project and therefore have no say in this ;) Hopefully soon :) |
Update: @ts-thomas just merged the fix into master, so it should be fixed if you're on current master now |
@theguy147 do you have any idea how this works with |
I also face this bug, what would be the workaround? |
1 similar comment
I also face this bug, what would be the workaround? |
I think the stable production version should not make such low-level mistakes |
Automated tests will be back in the next version. Sorry for the circumstances. This issue gets the top priority. |
Additional fix was added in v0.7.23 |
Hi,
Following the doc this sample code should work but it yields an empty array.
Any clues about what is done wrong?
The text was updated successfully, but these errors were encountered: