Skip to content

Conversation

deadem
Copy link
Contributor

@deadem deadem commented Oct 19, 2015

Small fix to allow sorting by meta-projections. This is needed for full-text search and sort results by relevancy. For example:

$query = Models\News::whereRaw([
   '$text' => [ '$search' => $request->Input('q') ]
])->project([ 'score' => [ '$meta' => 'textScore' ] ]);

$query->orderBy('score', [ '$meta' => 'textScore' ]);

http://docs.mongodb.org/manual/reference/operator/query/text/

@blitzfu
Copy link

blitzfu commented Dec 1, 2015

👍

jenssegers added a commit that referenced this pull request Dec 2, 2015
allow to sort by $meta-projection
@jenssegers jenssegers merged commit 64c4669 into mongodb:master Dec 2, 2015
hackel pushed a commit to arcstone/laravel-mongodb that referenced this pull request Dec 23, 2015
allow to sort by $meta-projection
mnphpexpert added a commit to mnphpexpert/laravel-mongodb that referenced this pull request Sep 2, 2024
allow to sort by $meta-projection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants