distantnative / search-for-kirby

Kirby 3 plugin for adding a search index (sqlite or Algolia).
43 stars 3 forks source link

Non-existent index #14

Closed nilshoerrmann closed 3 years ago

nilshoerrmann commented 4 years ago

After installing the plugin the default SQLite database is created inside the media folder. As the database is still empty, the search will not work and throw errors in the console complaining about missing models. Of course, this happens because I didn't read the docs until the end and didn't notice there was more for me to do, but one of the following would be nice:

  1. If there is no existing search index, it would be nice if there was a note in the UI when trying to search: there could be an info in the result list why there were not results and what to do, maybe even providing a button to populate the index.
  2. If there is no existing search index, the plugin could start generating it automatically.
distantnative commented 4 years ago

I get your point - I'm just very unsure about the implementation yet.

Adding a check in the backend on every search action could be a performance hit. Auto-generating the index might be problematic with very big indexes. People would think it's broken cause nothing is happening. I feel like generating should be a deliberate action (when generating the whole index, incremental changes via hooks seem fine to me).

Showing feedback in the Panel could be fine... Just not a 100% sure yet if there is an easy way for the Panel to recognize when no index has been created yet vs. the search really having no results.

distantnative commented 4 years ago

One clear improvement should be to include something in the installation section of the docs (so it's not as easily overlooked)

nilshoerrmann commented 4 years ago

I agree, that auto-generating the index might not be a good idea. There are two approaches that come to my mind:

  1. At some place, you'll have to check if the database exist at all before querying it. Currently, an empty database is created in that case. You could skip this step and just return an error in your search results so that the UI can react accordingly. This would make sure the system knows there is no index yet.
  2. Currently, if the index has not been populated yet, an error is thrown on search. The UI could react to that error.

With "reacting to the error" I mean something like displaying a message in the search result list or displaying a pop-up. In both cases, I'd like to get informed that the search has not been configured correctly. If I'm an admin, I'd like to see something like this:

The search has not been configured correctly. Please [check out the documentation](link/to/docs) for further information.

[ re-index site ]  [ OK ]

If I'm a normal user something more abstract would be fine, in order for me to know I should contact an admin:

Your search could not be performed due to an internal error.

[ OK ]

These are of course just ideas, but currently the UI doesn't reflect a misconfiguration at all. There is just nothing happening at all. And that's what I'd like to see changed. So in the end, maybe this issue is about handling exceptions in the broader sense, not just missing indexes. 🤔

One clear improvement should be to include something in the installation section of the docs (so it's not as easily overlooked)

That's a good idea because this plugin offers so many options that you can get lost a bit 😊

distantnative commented 3 years ago

✅

ezgif-3-3ca26b21c1dc

nilshoerrmann commented 3 years ago

Great, thanks!