The place to start is Beginner’s Guide to Creating Discourse Plugins Part 1: Creating a basic plugin. I believe you’ll need to get a good deal further to have a question that is small enough for anyone to offer much advice.
But maybe if you are getting your data for the search externally you could do it all in a theme component. Again, my best advice is to look at places on the discourse core that do the kind of search that you’re talking about, like the category and tag elements.