Skip to content
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

Document search with multiple fields #313

Closed
benstrum opened this issue Feb 24, 2022 · 3 comments
Closed

Document search with multiple fields #313

benstrum opened this issue Feb 24, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@benstrum
Copy link

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
        }
@amcclain
Copy link

I had the same question - believe this has already been asked via #257, which remains unanswered.

@brendanmoore
Copy link

I had the same question - believe this has already been asked via #257, which remains unanswered.

There is also this: #264 and this mystery #277

I have a feeling the git history has been lost for this fix

@ts-thomas ts-thomas self-assigned this Oct 2, 2022
@ts-thomas ts-thomas added the bug Something isn't working label Oct 2, 2022
@ts-thomas
Copy link
Contributor

This is now fixed in v0.7.23

ts-thomas added a commit that referenced this issue Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants