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

Support for $meta: 'textScore' #577

Closed
jgutix opened this issue Jun 5, 2020 · 5 comments
Closed

Support for $meta: 'textScore' #577

jgutix opened this issue Jun 5, 2020 · 5 comments

Comments

@jgutix
Copy link

jgutix commented Jun 5, 2020

Suggestion

I assume $meta: 'textScore' is not supported, so far I tried the following:

let references = await this.referenceRepository.find(
    {
      fields: {name: true, city: true, /*score: {meta: 'textScore'}*/}, //Error: Type '{ meta: string; }' is not assignable to type 'true'.
      where: {
        '$text': {search: param.reference},
        // score: {meta: 'textScore'} //500 MongoError: unknown operator: $meta
      },

      /*order: {
        score: {meta: 'textScore'} //Error: Type '{ score: { meta: string; }; }' is not assignable to type 'string[]'.
      }*/
    }, /*{score: {meta: 'textScore'}}*/); // doesnt work

Mostly what stop the implementation here is the type constraint on fields and order filters.

As a workaround I had to access directly to the mongodb's driver as shown here: https://gist.github.com/jgutix/71cbb8a9f5946ecd57328862154e3c15

Use Cases

Most of the time will go hand on hand with the use of $text search

Examples

Following the syntax from mongo driver:

let references = await this.referenceRepository.find(
    {
      fields: {name: true, city: true, score: {meta: 'textScore'}}, 
      where: {
        '$text': {search: param.reference},
      },
      order: {
        score: {meta: 'textScore'},
      }
    },);

Acceptance criteria

TBD - will be filled by the team.

@jgutix jgutix added the feature label Jun 5, 2020
@agnes512
Copy link
Contributor

agnes512 commented Aug 4, 2020

We're working on Repository.execute method that allows raw queries, see loopbackio/loopback-next#3342. I think once it is implemented, it would be a good workaround.

@stale
Copy link

stale bot commented Oct 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 4, 2020
@agnes512
Copy link
Contributor

@stale stale bot removed the stale label Oct 17, 2020
@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 25, 2020
@stale
Copy link

stale bot commented Jul 14, 2021

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

@stale stale bot closed this as completed Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants