Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Document store searchAsync function returns wrong fieldName #455

Open
noormohiuddin opened this issue Dec 19, 2024 · 2 comments
Open

Document store searchAsync function returns wrong fieldName #455

noormohiuddin opened this issue Dec 19, 2024 · 2 comments

Comments

@noormohiuddin
Copy link

Sample code

const { Document } = require('flexsearch');

const flexSearchDocument = new Document({
    tokenize: 'forward',
    document: {
        id: 'id',
        index: [
            'firstName',
            'lastName',
        ],
        store: true,
    }
});

for (let i = 1; i <= 2; i++) {
    flexSearchDocument.add(i, {
        firstName: 'John' + i,
        lastName: 'Doe' + i,
    });
}

const searchQuery = [
    { field: 'lastName', query: 'Doe' },
];

//Good: search will return lastName field
const searchResults = flexSearchDocument.search(searchQuery);
console.log('search:', JSON.stringify(searchResults));

//Bad: searchAsync will return firstName field
flexSearchDocument.searchAsync(searchQuery)
.then(asyncSearchResults => console.log('searchAsync:', JSON.stringify(asyncSearchResults)));

searchAsync expected output: [{"field":"lastName","result":[1,2]}]

searchAsync actual output: [{"field":"firstName","result":[1,2]}]

@noormohiuddin
Copy link
Author

Sorry @wwqwq2313 , wwqwq2313@32c2197 doesn't fix the issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@noormohiuddin and others