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

Weighted text search #98

Open
djdembeck opened this issue Oct 3, 2021 · 1 comment
Open

Weighted text search #98

djdembeck opened this issue Oct 3, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@djdembeck
Copy link

Hello,

I'm looking into adding text search with relevance scoring into my project. I see MongoDB has this feature (at least in 4.4+): https://docs.mongodb.com/v4.4/text-search/#sorting

It looks like Papr supports $text and $search already, but not score or .sort(). It also doesn't seem there is an index option in the Papr schema like Mongoose has: https://mongoosejs.com/docs/guide.html#indexes

@avaly avaly added enhancement New feature or request help wanted Extra attention is needed labels Oct 8, 2021
@djdembeck
Copy link
Author

Not super happy with how I was able to accomplish this, but here it is:

                Author.find(
                    { $text: { $search: name } },
                    { projection: { asin: true, description: true, image: true, genres: true, name: true, score: { $meta: 'textScore' } }, limit: 25, sort: { score: { $meta: 'textScore' } } },
                )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants