meilisearch icon indicating copy to clipboard operation
meilisearch copied to clipboard

Add index name to error message

Open tacman opened this issue 1 year ago • 17 comments

Describe the bug

 "Attribute `id` is not sortable. This index does not have configured sortable attributes.",

Expected behavior

I would LOVE to see the name of the index in this message.

 "Attribute `id` is not sortable. index 'Author' does not have configured sortable attributes.",

In particular, I do have sortable attributes:

http://127.0.0.1:7700/indexes/Author/settings

image

Perhaps the real issue is that the id is the primary key? More likely I'm using the wrong index, but I can't see what that is. A link to the settings would be even more awesome!

[EDIT] Indeed, I had something in my code that changed the name of the index, it was getting automatically created but was empty. Having the index name in the error message would have been very helpful.

tacman avatar Feb 06 '24 15:02 tacman

Hello @tacman Thank you for this report.

This would be a nice improvements

Any contribution is welcome ❤️

⚠️ More info for the contributor:

This issue is not hard, but not trivial. Knowledge in Rust are required. It will probably mean a lot of small mechanical changes to multiple files.

We would probably want the added context for most if not all milli::UserError . The thing is that in this location of the engine, we don't have the information of the index name. So it would have to be injected at the point where the error is caught in the webserver part of the engine, which will be many different points depending on where we're calling milli functions that can error

curquiza avatar Feb 08 '24 12:02 curquiza

Perhaps the change could be make in the meilisearch php library?

tacman avatar Feb 08 '24 12:02 tacman

We would rather handle this at the source (engine) than changing things in 10 library

curquiza avatar Feb 08 '24 12:02 curquiza

Makes sense. In addition to the index, I guess it'd be helpful to have all the details. Sometimes I run meilisearch in docker, and in different projects it listens on different ports, and sometimes calls a remote server. So in addition to the index, I'd want to know the server and port.

tacman avatar Feb 08 '24 12:02 tacman

We would rather not prioritize the port addition to solve this issue -> let's focus on the index name as a first step. From a product perspective, it does not seem relevant to us to have this information in the error, so we need more product discussion before validating it. We are a small team so we are careful about everything we add because can be tedious to update and maintain

Btw, as a workaround, in the meantime you can have all the information in the URL you try to reach: index name and port

curquiza avatar Feb 08 '24 14:02 curquiza

I would like to see if I can work on this issue, would that be ok?

ghost avatar Feb 12 '24 11:02 ghost

Hello @cisco877

Thanks for your interest in this project 🔥 You are definitely more than welcome to open a PR for this!

For your information, we prefer not assigning people to our issues because sometimes people ask to be assigned and never come back, which discourages the volunteer contributors from opening a PR to fix this issue. We will accept and merge the first PR that fixes correctly and well implements the issue following our contributing guidelines.

We are looking forward to reviewing your PR 😊

curquiza avatar Feb 12 '24 11:02 curquiza

Can someone write me the steps to replicate the issue? Maybe I can give it a try.

postmeback avatar Aug 03 '24 13:08 postmeback

Hey, you should create an index with the method of your choice: https://www.meilisearch.com/docs/reference/api/indexes#create-an-index For example in terminal you would run:

curl \
  -X POST 'http://localhost:7700/indexes' \
  -H 'Content-Type: application/json' \
  --data-binary '{
    "uid": "movies",
    "primaryKey": "id"
  }'

And then do a search with a filter on any field https://www.meilisearch.com/docs/reference/api/search#search-in-an-index-with-post In terminal again it could be this request:

curl \
  -X POST 'http://localhost:7700/indexes/movies/search' \
  -H 'Content-Type: application/json' \
  --data-binary '{ "filter": "title = Kefirausaurus" }'

And this is the response you'll receive:

{
  "message": "Attribute `title` is not filterable. This index does not have configured filterable attributes.\n1:6 title = Kefirausaurus",
  "code":"invalid_search_filter",
  "type":"invalid_request",
  "link":"https://docs.meilisearch.com/errors#invalid_search_filter"
}

irevoire avatar Aug 06 '24 07:08 irevoire

@irevoire Yes, but I have hundreds of indexes. "This index" is ambiguous, it'd be trivial to replace that generic term with the index name, so I knew exactly which index was causing the problem. Especially since you can prefix the indexes when in development, so it's a lot of work to hunt down just the name of the index.

tacman avatar Aug 06 '24 12:08 tacman

@tacman Yes, I was just giving a reproducer for @postmeback, who wants to work on it

irevoire avatar Aug 06 '24 12:08 irevoire

Got it, thanks!

tacman avatar Aug 06 '24 12:08 tacman