A search bar is necessary for a good website. Creating your own search engine from scratch might be a difficult task but this task can be skipped with the help of Google. Google has created a website to create a custom search bar, to create your own check the below link.
Creating a Custom Search Bar:
On this website, anyone can easily program their search bar by just selecting the sites you want to be searched for. Follow the steps explained below.
Go to the following site (https://programmablesearchengine.google.com/about/ and hit Get Started button.
Select the New search engine button to create a new search engine.
Fill the details as directed on the page and then click the create button.
After hitting create you will get your code by hitting the Get Code button on the screen shown.
Note: .You can modify your setting about searching sites, searching images, safe search from control panel and you can also set to show advertisement while searching through your search ba. Embedding the Search Bar on a Webpage: Atter getting your code you can simply paste it inside your web page to see the working search bar.
Example: You can see that the output screen has a search bar with an option to search which shows the result from the sites or domain you have selected while creating this search bar. Moreover, this search option will automatically change as you change the sites from the control panel. Currently, the search results are been shown in the default manner. Apart from that, you can manipulate the result displaying manner and much more as directed on the below links