This page applies to Apigee and Apigee hybrid.
View
Apigee Edge documentation.
To enable search of the publicly available content in your portal, you can create a dedicated search page where you embed a Google Custom Search Engine (CSE).
To create a custom search page:
- Publish your portal content.
Create a Google custom search engine:
- Navigate to the Google custom search configuration page.
- Click Add to create a new custom search engine.
- Configure your custom search engine and identify the portal site domain.
See Create a search engine in the Google Custom
Search Help. The custom search configuration returns something like
the following:
Where<script async src="https://cse.google.com/cse.js?cx=e13bcb52d46f04dfd"></script> <div class="gcse-search"></div>
cx=e13bcb52d46f04dfd
is the Google search engine ID.
Add the following custom script to your portal. See Adding custom scripts.
Set the
cx
variable to your Google search engine ID, for examplee13bcb52d46f04dfd
, and thepath
value to your search page URL, for example,/search
.<script> window.portal = { pageEventListeners: { onLoad: (path) => { // Update with your search page URL if (path === '/your-search-page-URL') { // Add your Google search engine ID var cx = 'your-search-engine-id'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = 'https://cse.google.com/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); gcse.onload = function () { var search = document.createElement('gcse:search'); // Note the element ID name var searchBox = document.getElementById('search-box'); searchBox.appendChild(search); }; } } } }; </script>
Create a new search page in your portal and customize it as described in Manage pages in your portal.
Add the custom search element ID (
search-box
) defined in your custom script at the location that you want the Google search box to appear. For example<div id="search-box"></div>
Add the search page to your portal navigation, as described in Set up navigation.
Publish your search page and navigation updates.