Skip to content

Results in statamic don't match meilisearch dashboard results #17

Answered by earthwytch
earthwytch asked this question in Help
Discussion options

You must be logged in to vote

Worked it out. Needs to have the "score" added as in https://statamic.dev/extending/search#create-query-builder

    public function getSearchResults()
    {
        $results = $this->index->searchUsingApi($query);
 
        // Statamic will expects a search_score to be in each result.
        // Some services like Algolia don't have scores and will just return them in order.
        // This is a trick to set the scores in sequential order, highest first.

        return $results->map(function ($result, $i) use ($results) {
            $result['search_score'] = $results->count() - $i;
            return $result;
        });
    }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by earthwytch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant