Change the order on the /documents route output #103
Replies: 6 comments
-
Hello @gorkagv! Ranking rules are not applied on Here is the related documentation: https://docs.meilisearch.com/reference/features/search_parameters.html#query-q |
Beta Was this translation helpful? Give feedback.
-
I am using “meilisearch / meilisearch-vue” like in this example -> https://codesandbox.io/s/ms-vue-is-1d6bi?fontsize=14&hidenavigation=1&theme=dark In the documentation I have found this in the ranking rules section (https://docs.meilisearch.com/reference/api/ranking_rules.html#update-ranking-rules):
but when I do some search or get all results (without doing any search) the results are not sorted by the attributes “date” or “name”, the results are sorted by PrimaryKey. How could I sort the results by those attributes?. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
-
Hey @gorkagv as this is a issue linked to meilisearch/meilisearch I will move your issue. |
Beta Was this translation helpful? Give feedback.
-
Hello @gorkagv can you send us your dataset and your detailed steps so that we can reproduce your search? |
Beta Was this translation helpful? Give feedback.
-
For privacy reasons I cannot send the dataset. But in this example dataset -> https://codesandbox.io/s/ms-vue-is-1d6bi?fontsize=14&hidenavigation=1&theme=dark How could I sort the results list by date or alphabetically? I have tried adding two parameters (“desc(date)",“asc(name)”) to the ranking rules in my dataset, but the results are not ordered by those parameters. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
-
Hello @gorkagv, I've seen you linked the dataset we are using for our demo: all the fields have string values and the custom ranking rules ( The docs link: https://docs.meilisearch.com/reference/features/settings.html#custom-ranking-rule If it's the case for your dataset, it's why it does not work. FYI, we are considering allowing the strings in the custom ranking, but you have to be aware this would impact the performance of the search. |
Beta Was this translation helpful? Give feedback.
-
Hi.
Currently when doing an index search (/ indexes /: index_uid / documents), the documents are sorted by primaryKey by default, in my index the primaryKey is "eId".
{
"eId": 31,
"name": "Charles”,
..
},
{
"eId": 32,
"name": "Ingrid”,
..
},
{
"eId": 33,
“name”: “Robert”,
..
},
{
"eId": 34,
“name”: "Garcia”,
..
},
Is there a way to sort the index by multiple attributes (eg name), instead of the default sort?
I have added a ranking rule using “/ indexes /: index_uid / settings / ranking-rules”:
"typo", "words", "proximity", "attribute", "wordsPosition", "exactness", "desc(name)"
but the results are still sorted by the primaryKey instead of the “name” attribute.
I have rebuilt the index using the commands “php artisan scout:flush “Model”” and “php artisan scout:import “Model””
I have also tried this: "typo", "desc(name)”, “words", "proximity", "attribute", "wordsPosition", "exactness" using “/ indexes /: index_uid / settings / ranking-rules” but the results are still sorted by the primary key.
Beta Was this translation helpful? Give feedback.
All reactions