In this article, we will see how to implement a hosted search API using expertrec.
What is hosted search?
Hosted means- the search engine data resides in the servers of the search engine provider (in this case, expertrec’s servers). This means that all the processes (crawling, indexing and returning search results when a search query is made ) related to making search working on your website, is done on an external server. This means that your website resources are not used when a user types in the search box of your website. It is like renting an external search solution to search within your website.
What is an API?
Technically, API is the short form of Application programming interface. In common man’s language, API is a way of communicating with any software. When you call an API (for example open the API URL in a browser, it gives some results) You can consume these results in ways you want it.
What is a hosted search API?
It simply means that an external search vendor creates a search engine for you that is residing in his servers and he gives access to your search engine results whenever you call his API.
You can use these results to build your own search engine. You can choose either the default search engine template or or you can build your own search engine user interface. you can also control the search engine ranking and add custom rules using the hosted search API.
Here is a snapshot of expertrec’s hosted search API.
There are two different kinds of hosted search APIs.
- Custom search hosted API (for content websites)
- E-commerce search autocomplete API.
- E-commerce search results page API.
The results of this API call would be in JSON format. The API Call format is
https://searchv7.expertrec.com/v6/search/{org_id}/?q={keyword}&page={pagination}&size={number_of_search_results}
Expertrec site search API parameters-
- org_id- Your unique ID that identifies your website/ websites.
- q- Keyword.
- page- pagination
- size- number of search results to be displayed.
https://searchv7.expertrec.com/v6/suggestion/api_key/?q={search_query}&ssize={suggestion_size}&psize={popular_products_size}&csize={category_size}
- api_key– Can be obtained from your control panel (uniquely identifies your website).
- q-search query (example- apple)
- ssize– number of search suggestions (numeric value)
- psize-number of popular products.(numeric value)
- csize– number of categories to be displayed.
Hosted e-commerce search results API
https://searchv7.expertrec.com/v6/search/api_key/?q={search_query}&size={number_of_search_results}&page={pagination}&fq={facet_query}&nf={numeric_search_filters}&sort={sort_search_results}
- api_key– Can be obtained from your control panel (uniquely identifies your website).
- q-search query (example- apple)
- size– number of search results (example -15)
- page – pagination (example -0, 1, 2…10)
- fq– facet query (example- fq=category:”Apple”) the facet of filter the user clicks on.
- nf- numeric filter query( for price range filters. example- price:400-1000)
- sort-sort search results (example: score:desc (for descending (high to low) and score:asc (for ascending(high to low))
Add Search to your Wordpress Website