Pour activer la recherche de contenu accessible au public sur votre portail, vous pouvez créer une page de recherche dédiée sur laquelle vous intégrez un Moteur de recherche personnalisé Google (MRP). Par exemple, le portail affiché dans la figure suivante intègre un moteur de recherche personnalisé Google permettant d'effectuer des recherches parmi le contenu indexé par Google.
Pour créer une page de recherche personnalisée, procédez comme suit :
Créez un moteur de recherche personnalisé Google :
a. Accédez à la page de configuration de la recherche personnalisée Google.
b. Cliquez sur Add (Ajouter) pour créer un moteur de recherche personnalisé.
c. Configurez votre moteur de recherche personnalisé et identifiez le domaine du site du portail. Consultez la page Créer un moteur de recherche dans l'aide dédiée à la Recherche personnalisée Google.
d. Accélérez l'indexation du site en le validant et en le publiant à l'aide de Google Search Console. Consultez la page Valider votre site dans Search Console dans l'aide dédiée à la recherche personnalisée Google.
Créez une page de recherche sur votre portail et personnalisez-la comme vous le souhaitez. Consultez la page Gérer les pages de votre portail.
Ajoutez l'ID de l'élément de recherche personnalisé (search-box) défini dans votre script personnalisé à l'emplacement où vous souhaitez voir apparaître le champ de recherche Google.
Exemple :
<div id="search-box"></div>
Ajoutez la page de recherche aux liens de navigation de votre portail, si nécessaire. Pour en savoir plus, consultez la page Configurer la navigation.
Publiez votre page de recherche et les mises à jour des liens de navigation.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/09 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/09 (UTC)."],[[["\u003cp\u003eThis content pertains to setting up a search function within Apigee and Apigee hybrid portals using Google Custom Search Engine (CSE).\u003c/p\u003e\n"],["\u003cp\u003eGoogle CSE can only return results for content that is publicly accessible, without requiring user sign-in, and ads cannot be disabled unless you're an approved non-profit.\u003c/p\u003e\n"],["\u003cp\u003eCreating a custom search page involves publishing portal content, setting up the search engine through Google's configuration page, adding a custom script to your portal, and integrating the search box into your portal pages.\u003c/p\u003e\n"],["\u003cp\u003eImplementing a Google Custom Search Engine requires setting the \u003ccode\u003ecx\u003c/code\u003e variable to your Google search engine ID, and the \u003ccode\u003epath\u003c/code\u003e value to your search page URL in the provided script.\u003c/p\u003e\n"],["\u003cp\u003eAfter publication, it may take several days or even up to a month before Google fully indexes your site's content, so it is advised to test over time and potentially delay publishing the search page.\u003c/p\u003e\n"]]],[],null,["# Creating a custom search page\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\n\n*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*\n\n\u003cbr /\u003e\n\nTo 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)](https://cse.google.com).\n\n| Before embedding a Google custom search engine, note the following:\n|\n| - Search using a Google CSE can return only results for **publicly available content**. In other words, a portal user must not be required to sign in to the portal to view the content.\n| - At this time, you cannot disable ads in search results unless you are an approved non-profit site.\n| - Google CSE is not included with an Apigee license. (An out-of-the-box search solution in the integrated portal is planned for a future release.)\n| - The [Google Search Console](https://search.google.com/search-console/about) (also not included with an Apigee license) is another tool you may use to remove or manage your portal's presence in Google's search index.\n\nTo create a custom search page:\n\n1. [Publish your portal content](/apigee/docs/api-platform/publish/portal/portal-publish).\n2. Create a Google custom search engine:\n\n 1. Navigate to the [Google custom search](https://cse.google.com/cse) configuration page.\n 2. Click **Add** to create a new custom search engine.\n 3. Configure your custom search engine and identify the portal site domain. See [Create a search engine](https://support.google.com/programmable-search/answer/11082370?ref_topic=4513742) in the Google Custom Search Help. The custom search configuration returns something like the following: \n\n ```text\n \u003cscript async src=\"https://cse.google.com/cse.js?cx=e13bcb52d46f04dfd\"\u003e\u003c/script\u003e\n \u003cdiv class=\"gcse-search\"\u003e\u003c/div\u003e\n ```\n Where `cx=e13bcb52d46f04dfd` is the Google search engine ID.\n\n | **Tip:** You can expedite site indexing by verifying and submitting your site using Google Search Console. See [Verify your site in Search console](https://support.google.com/customsearch/answer/2402989?ref_topic=4513742%22%20class=%22external) in the Google Search Console Help.\n3. Add the following custom script to your portal. See [Adding custom scripts](/apigee/docs/api-platform/publish/portal/custom-scripts).\n\n Set the `cx` variable to your Google search engine ID, for example\n `e13bcb52d46f04dfd`, and the `path` value to your search page URL,\n for example, `/search`. \n\n \u003cscript\u003e\n window.portal = {\n pageEventListeners: {\n onLoad: (path) =\u003e {\n // Update with your search page URL\n if (path === '/your-search-page-URL') {\n // Add your Google search engine ID\n var cx = 'your-search-engine-id';\n var gcse = document.createElement('script');\n gcse.type = 'text/javascript';\n gcse.async = true;\n gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;\n var s = document.getElementsByTagName('script')[0];\n s.parentNode.insertBefore(gcse, s);\n gcse.onload = function () {\n var search = document.createElement('gcse:search');\n // Note the element ID name\n var searchBox = document.getElementById('search-box');\n searchBox.appendChild(search);\n };\n }\n }\n }\n };\n \u003c/script\u003e\n\n4. Create a new search page in your portal and customize it as described in\n [Manage pages in your portal](/apigee/docs/api-platform/publish/portal/portal-pages).\n\n5. Add the custom search element ID (`search-box`) defined in your custom\n script at the location that you want the Google search box to appear.\n For example\n `\u003cdiv id=\"search-box\"\u003e\u003c/div\u003e`\n\n6. Add the search page to your portal navigation, as described in\n [Set up navigation](/apigee/docs/api-platform/publish/portal/portal-menus).\n\n7. Publish your search page and navigation updates.\n\n| It takes time for Google to index your site so you may not see search results right away. (It can take a couple of days up to a month to complete full indexing.) You may want to delay publishing the search page until you have tested your portal site search (over time) and are satisfied with the results being returned."]]