Searching for Content¶
All indexed content (a.k.a. assets in Liferay DXP) can be returned as search results. Custom content can also be indexed, so your installation might have additional asset types beyond the ones included by default. The following image shows an example of the different types of content that is indexed in Liferay DXP:
Using the Search Bar¶
Using the default Liferay DXP setup, users can engage with search by entering search terms in the Search Bar. Execute a search and you’re taken to a search page with various search widgets deployed.
Entering Search Terms¶
Full text search compares all the words entered in a search query (for example, stock market) to all the words in each indexed document. A search engine like Elasticsearch calculates relevance scores to ensure the best results are returned first (like a Blogs Entry about a recent bull market). Anything with words like stock or market is returned.
Matching Exact Phrases: Quoted Search¶
What if users want their search terms (for example, agile frameworks) to produce only results with the exact phrase, as typed? In a regular full text search, searching agile frameworks returns search results containing just the terms agile and frameworks, and hits containing both terms but separated by other text, as well as results with the exact phrase match. To ensure that only hits with the exact phrase are returned, enclose it in quotes: “agile frameworks”.
With prefix searching, searching for the term instrument returns documents not only containing the full word, but also variants with instrument as the prefix. For example, results with instruments, instrumental, and instrumentation are also returned.
Prefix searching is available for many fields out of the box, but it’s more complicated under the hood. The details of the field mapping, including the analyzer used on the field and any transformations performed, determine the final behavior.
Another way to ensure users see results is through search suggestions.
Configuring the Search Bar¶
The Search Bar’s behavior can be configured via its portlet configuration screen.
When you configure the globally embedded Search Bar widget at the top of one page, it configures the page-top Search Bar widget on all pages in the site. It also overrides the destination Search Page’s Search Bar portlet, if they’re configured differently. However, it does not override Search Bar widgets manually placed on other pages.
There are several options:
Keywords Parameter Name: Edit the parameter name for the keywords entered in the search. For example, the default URL when searching for the keyword term data looks like this:
If you change the Keywords Parameter Name to keyword it looks like this:
Scope: Choose between three options: This Site (default), Everything, and Let the User Choose. This Site means only the assets associated with the site where the search is executed are searched. Expand the scope of the search to all sites by selecting Everything. To let users choose which scope they want to search, select Let the User Choose.
Scope Parameter Name: Set the URL parameter name for the scope where the search is taking place. This parameter only appears in the URL if the scope Let the User Choose is selected. The default value is scope, so searching for the word data produces the default URL of
Changing scope to target would produce this URL:
Destination Page: Provide a friendly URL to the search page. If not configured or if it points to a page that doesn’t exist, a message appears for administrators that the search bar must be configured for it to appear to users.