Configure Search
You can configure Retail Digital Commerce search features that enable shoppers to search for products and other items in an OSF application.
This section describes how to configure search services and the search typeahead feature in an OSF application. For more information about configuring these and other search features, see Configure Search Features.
Configure Search Services
Each OSF application includes its own search configuration
files that control the application’s search features,
such as guided navigation. These files are found under
the workspace's packages/apps/{appName} directory.
Several of the widgets included with OSF use these
configuration files to determine some aspects of their
behavior.
The primary search configuration file is for the catalog search service. The location of this file within the application directory is:
config/search/config/pages/Default/osf/catalog.js Each OSF accelerator template includes a sample catalog.js file. You can copy this file
to your own application and modify it.
You can
configure other search services for an application by creating a
new service-name.js file in the directory config/search/config/pages/Default/osf. For example, you could add a file named store-locations.js to this directory with
configuration for the Store Locations search service.
Note that you can use whatever naming convention you want
for these search configuration files, but the name you give a configuration
file is then used as a path parameter in REST API
endpoints that access the service configured by the file.
For example, for a configuration file named store-locations.js, the endpoints for accessing the configuration would use the following
path:
/gsadmin/v1/cloud/pages/Default/osf/store-locations Endpoints for querying the search service would use this path:
/ccstore/v1/assembler/pages/Default/osf/store-locations Upload search configuration files
To upload search configuration files to the administration
server, use the upload-search-config command:
yarn occ upload-search-config This command uploads all search configuration files
in the application's config/search/config/pages/Default/osf folder to the preview context. You can then promote
these files to the live context by publishing them.
Configure Typeahead Keywords
In addition to the files for configuring search services, you can create a file for specifying custom typeahead keywords for an application. The location of the file within the application directory is:
config/search/data/keywords.js Each OSF accelerator template includes a sample
keywords.js file. You can copy
this file to your own application and modify it.
When you upload the keywords.js file,
the records in the file are appended to any existing custom typeahead
keyword records. You can instead delete the existing custom keywords
before adding the ones in the file by uncommenting the following lines:
// {
// // Uncomment this "deleteAll" record to truncate existing
// // supplemental(custom) typeahead keyword records.
// 'record.action': 'deleteAll'
// },
Upload a keyword file
To upload a keywords.js file to the administration
server, use the upload-custom-typeahead-keywords command:
yarn occ upload-custom-typeahead-keywords After you upload the file, make the keywords available
by using the POST /ccadmin/v1/search/index endpoint
to initiate indexing.