flexsearch
flexsearch copied to clipboard
Document search with multiple fields
I am trying to get Document searching to work using an array of criteria as the first param. From the documentation, it appears you should be able to do something like this:
index.search([{
field: "content",
query: "some query",
limit: 100,
suggest: true
},{
field: "content",
query: "some other query",
limit: 100,
suggest: true
}]);
However, the issue appears to be that the code for Document.search does not properly set the query variable in the loop here:
https://github.com/nextapps-de/flexsearch/blob/master/src/document.js#L552
Thus query is null when the code gets here: https://github.com/nextapps-de/flexsearch/blob/master/src/document.js#L552
res = this.index[key].search(query, limit, opt || options);
I believe this can easily be fixed by doing the following
for(let i = 0, res, key, len; i < field.length; i++){
let opt;
key = field[i];
if(!is_string(key)){
opt = key;
key = key["field"];
query = key["query"]; // (NEW) set the query variable
}
I had the same question - believe this has already been asked via #257, which remains unanswered.
I had the same question - believe this has already been asked via #257, which remains unanswered.
There is also this: https://github.com/nextapps-de/flexsearch/issues/264 and this mystery https://github.com/nextapps-de/flexsearch/pull/277
I have a feeling the git history has been lost for this fix
This is now fixed in v0.7.23