Help Implementing Search Handler

Hey guys,

Anyone successfully created search handler and resources classes for any the modules or knows how to? Please reach out. I am having abit of an issue creating the log entry search handler and linking it to the resource

The reportingrest module is a good example, did you take a look at this page? If you think there is something missing or unclear, please let us know and we update it.

Thanks @Wyclif, I did look at the step by step guide and it was helpful in getting me started but I havent been able to get the search to work as expected. Let me look through the reporting rest module to see what I may be missing out or where I could be going wrong

@wyclif the reporting rest module doesn’t have an implemented searchhandler. The problem I am having now is search handler related, the LogEntrySearchHandler class I created is pretty much redundant so I moved the code to the doSearch Method in the LogEntryResource class (which I know aint right) and it is even not working as it should. If possible, please take a look at the repo or PR I raised and advise accordingly

Module search handlers aren’t that special or different from those in the core rest module, they are just spring beans with a couple of extra annotations that are independent of whether they are in another module or not, but if they are not well setup, they can easily fail to work, are your other regular rest resources working anyways? Here is an example of a search handler in a module, you might want to pay extra attention to the getSearchConfig() method, the query and SUPPORTED_VERSIONS fields to see how they are setup, you want to make sure the supported versions cover the core version(s) you intend to run against, this is a common pitfall when setting up rest resources so you might want to double check it, I added a comment to the PR.

I’m trying to figure out the procedure for implementing search on a resource. I thought implementing a search handler is sufficient but looking at @nagadya PR , I see that she implemented a doSearch and a search handler, is this necessary? If not how do I know what to use and when to use what?

cc @wyclif

FYI, search handler without Resource.doSearch, worked for me. Would still like to know why I should use the doSearch though

You should be implementing the search() method

1 Like

I remember I had an issue including the doSearch yet it is not any different from the search handler though I had errors if I eliminated it and noticed it was included in all other similar resouce classes. Didn’t manage to get an answer why but I think @dkayiwa can help out here.

Apologies for the delayed response. Still recovering from Christmas break as the brain seems to be held up in holiday mode:grimacing:

1 Like