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 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.
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.
7.4 U36+ and GA36+
Out of the box on the most recent Liferay 7.4, the Search bar provides search suggestions as users type their search phrases:
For the details on how it works, see Search Bar Suggestions
Wrapping search bar queries in quotation marks forces the search engine to produce matches more strictly. The exact behavior depends on the type of field being searched.
Placing search bar queries in quotes matches the searched terms to the field only if they appear in the exact same order. The search engine does not match the exact quoted phrase, because analysis still takes place on the indexed content and the search phrase.
Consider a blog entry including this text in its
Bring to the table win-win survival strategies to ensure proactive collaboration.
With the default English analyzer, the search phrase “strategy that ensures” returns this blog entry. The same analysis is performed on the search keywords and the indexed text, accounting for stemming, stop word removal, and other tokenization. Quoting the phrase enforces that the separate tokens in the phrase match with the tokens in the indexed document field, including their relative position to each other.
By contrast, entering the search keywords “strategies ensure” will not return the above blogs entry document, because the relative position of the tokens produced by analysis are different between the search keywords and the indexed content.
When searching non-analyzed fields (e.g., keyword fields), a quoted search phrase and the field value must match exactly.
In a regular Liferay search, both analyzed and non-analyzed fields are present in index documents. The non-analyzed fields produce results only if their content matches the quoted search phrase exactly, while the analyzed fields produce results as long as their tokens match the quoted search phrase’s tokens and they appear in the same relative positions.
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.
The Search Bar’s behavior can be configured via its widget configuration screen. Configuration options are categorized as Display Settings, Suggestions Configuration, or Advanced Configuration.
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 widget, if they’re configured differently. However, it does not override Search Bar widgets manually placed on other pages.
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.
If Search Bar Suggestions is available and enabled, additional configurations appear in the Search Bar widget configuration. See Configuring Search Bar Suggestions to understand these configuration options.
Show Results from Staged Sites: Content from Staging environments is not searchable on live sites, regardless of this setting. This setting enables searching for content from other local staging sites when the Everything scope is configured in a site with local staging enabled.
Liferay 7.4 includes Liferay Objects, a GUI-driven application-building framework. Fields of each Object’s definition can be declared searchable; Object Entries (the records submitted by the application’s users) can then be queried and returned in the Search Results widget.
The scope of the Object determines how it must be searched:
- If the scope of the Object is Company, the Object’s Entries are only searched when the Search Bar is configured to search Everything.
- If the scope of the Object is Site, the Object’s Entries can be searched when the Search bar is configured to search in This Site.
The Type Facet and the Search Results widget support searching for Liferay Objects in the following manner:
The Type Facet automatically includes published Objects:
The Search Results widget automatically displays the Object Entry’s title and a summary.
For Liferay 7.4 U64+/GA64+, clicking an object entry in search results redirects to the entry’s display page, if one exists.