How to add a SearchProvider?

Hi there, I tried to add a SearchProvider for my app to the list of search providers in the new unified search bar introduced in NextCloud 20. Nevertheless, NC does not seem to add my search provider to the list of search providers, also I have created a class for it and registered this class in my Application.php. Is there anything else I have to bethink?

Thanks a lot!

https://docs.nextcloud.com/server/20/developer_manual/digging_deeper/search.html

As starting point. It might be easier to share your code.

https://github.com/nextcloud/server/blob/master/core/Controller/SearchController.php is the controller. I would set a break point there and go through the code to figure out if the search provider is registered and/or why does not respond properly.

Okay, I could narrow the problem down to one line in the SearchComposer: https://github.com/nextcloud/server/blob/0c899544887ed548c2d62c9157a67ee7f322c10a/lib/private/Search/SearchComposer.php#L99

Now I am not sure why I cannot query my own search provider even so it is registered.

Okay, problem solved. I searched hours through the source and dependencies of NextCloud, learnt a lot of stuff, and finally I realized, that there was one application related error message in my log: the search provider could not be loaded because I missed to add the use statement for the IURLGenerator. Dammit.

So. Problem solved :joy:

1 Like