-
Notifications
You must be signed in to change notification settings - Fork 36
Configuration
Every Liferay GSearch module has its' own configuration which can be found in Control Panel -> Configuration -> System Settings -> Other.
There's some basic documentation below but the ultimate source of information is the source code of this application and Elasticsearch documentation.
If you are having problems with configuration (portlet stops working) it's usually because of malformed JSON. Please see the Tomcat log first, if you're having problems.
The most important one is the GSearch Core configuration as the application doesn't work at all it that's not done. An easy way to start is to copy the default configuration file from the latest folder to LIFERAY_HOME/osgi/configs. Below are some instructions how to configure the core.
Note that field names and values are case sensitive. Configuration syntax is JSON.
Depending on the configuration, following variables can be used:
- $language_id (Current user's language id, for example 'fi_FI'
This is the comfiguration for keywords suggester i.e. "autocompletion".
It's possible to use either a single suggester or an aggregated one. In either case, if you customize the sample settings below, there has to be a corresponding Elasticsearch configuration in place. Please see the custom Elasticsearch adapter JSON configuration files for examples.
About fields and values:
Key | Supported values | Explanation |
---|---|---|
suggesterType | phrase,completion | Suggester type. See ES docs. |
fieldName | * | The name of the suggestion field. |
numberOfSuggestions | * | Maximum number of suggestion to show. |
confidence | * | Applies only to phrase type. Please see ES docs. |
gramSize | * | Applies only to phrase type. Please see ES docs. |
maxErrors | * | Applies only to phrase type. Please see ES docs. |
realWordErrorLikelihood | * | Applies only to phrase type. Please see ES docs. |
analyzer | * | Applies only to completion type. Please see ES docs. |
If you don't want to use the custom Elasticsearch adapter (loosing much of the suggester functionalities), please use the configuration below. This uses the standard suggestion mapping.
[
{
"suggesterType": "phrase",
"fieldName": "keywordSearch_$language_id",
"numberOfSuggestions": 5,
"confidence": "0.1f",
"gramSize": "2",
"maxErrors": "2.0f",
"realWordErrorLikelihood": "0.95f"
}
]
If you are using the custom Elasticsearch adapter, please use this one with an improved mapping and analysis:
[
{
"suggesterType": "phrase",
"fieldName": "keywordSearch_$language_id.ngram",
"numberOfSuggestions": 5,
"confidence": "0.1f",
"gramSize": "2",
"maxErrors": "2.0f",
"realWordErrorLikelihood": "0.95f"
},
{
"suggesterType": "completion",
"fieldName": "keywordSearch_$language_id.suggest",
"numberOfSuggestions": 5
}
]
This configuration defines the asset types to search for.
Fields and values:
Key | Supported values | Explanation |
---|---|---|
key | * | This is used as a parameter key (what you see in URL). |
entryClassName | * | The class name to search for in "entryClassName" field |
The default configuration:
[
{
"key": "web-content",
"entryClassName": "com.liferay.journal.model.JournalArticle"
},
{
"key": "file",
"entryClassName": "com.liferay.document.library.kernel.model.DLFileEntry"
},
{
"key": "discussion",
"entryClassName": "com.liferay.message.boards.kernel.model.MBMessage"
},
{
"key": "blog",
"entryClassName": "com.liferay.blogs.kernel.model.BlogsEntry"
},
{
"key": "wikipage",
"entryClassName": "com.liferay.wiki.model.WikiPage"
},
{
"key": "non-liferay-type-example",
"entryClassName": "non-liferay-type"
}
]
This configuration defines the facets in the secondary filter menu on the UI. You can add there any indexed field.
Fields and values:
Key | Supported values | Explanation |
---|---|---|
paramName | * | Parameter key (what you see in URL). |
fieldName | * | The indexed field name. |
icon | * | Path to icon (not currently implemented). |
aggregations | Here you can aggregate values into a single type shown in the UI. See the default configuration as an example how you can aggregate multiple image formats to just one visible facet value "Image" | |
isMultiValued | true, false | Allow selecting multiple values. |
Default configuration:
[
{
"paramName": "entryClassName",
"fieldName": "entryClassName",
"isMultiValued": false,
"icon": "icons/icon-ddm-structure.png"
},
{
"paramName": "ddmStructureKey",
"fieldName": "ddmStructureKey",
"isMultiValued": true,
"icon": "icons/icon-ddm-structure.png"
},
{
"paramName": "fileEntryTypeId",
"fieldName": "fileEntryTypeId",
"isMultiValued": true,
"icon": "icons/icon-file-entry-type.png"
},
{
"paramName": "extension",
"fieldName": "extension",
"isMultiValued": true,
"icon": "icons/icon-file-extension.png",
"aggregations": [
{
"key": "Image",
"values": "png,jpg,gif"
},
{
"key": "MS Word",
"values": "doc,docx"
},
{
"key": "MS Excel",
"values": "xls,xlsx"
},
{
"key": "MS Powerpoint",
"values": "ppt,pptx"
},
{
"key": "Video",
"values": "mp4,avi"
},
{
"key": "Audio",
"values": "mp3"
}
]
},
{
"paramName": "userName",
"fieldName": "userName",
"isMultiValued": true,
"icon": "icons/icon-user.png"
},
{
"paramName": "assetCategoryTitles",
"fieldName": "assetCategoryTitles",
"isMultiValued": true,
"icon": "icons/icon-category.png"
},
{
"paramName": "assetTagNames",
"fieldName": "assetTagNames.raw",
"isMultiValued": true,
"icon": "icons/icon-tag.png"
}
]
Sort fields. You can add there any indexed and sortable field. Translations need to be added to gsearch-core-api module localization file.
About fields and values:
Key | Supported values | Explanation |
---|---|---|
key | Parameter key (what you see in URL). Used also for translation. | |
fieldName | * | The name of the suggestion field. |
fieldType | 0-10 | Sort field type. Please see Sort.java for the available values. |
default | true, false | Is this the default sort field |
[
{
"key": "_score",
"fieldType": 0,
"default": true
},
{
"key": "title",
"fieldName": "localized_title_$language_id_sortable",
"fieldType": 3,
},
{
"key": "modified",
"fieldName": "modified_sortable",
"fieldType": 6,
}
]
This defines the main query. You can have there just a single query or construct it of many queries. The supported types ("queryType") at the moment are query_string, match, term and wildcard. Please see the gsearch-core-impl module QueryBuilders code for more information.
About fields and values:
Key | Supported values | Explanation |
---|---|---|
queryType | query_string, match, term, wildcard | Query type. Please see ES docs |
occur | must, should, not | Whether this clause must occur, should occur or should not occur |
operator | and, or | Operator |
boost | [float value] | Boost value. Default 1.0 |
fuzziness | Fuzziness. Please see ES docs | |
fields | An array of fields to search for | |
keywordSplitter | For wildcard query only. | |
valuePrefix | For wildcard query only. | |
valueSuffix | For wildcard query only. |
The default configuration below defines two should (OR) queries and one must query. In the first, all the keywords have to match (AND) and it gets a boost of 3. In the second, any of the keywords can match and it gets only a boost of 1.5. Match to this query is the minimum requirement. The third query gives a boost of 1 if any of the keywords match the userName field. In other words, following results can be expected from this query configuration: documents matching all the keywords get to the top of the search results, documents matching just some of the keywords are secondary and any keywords matching the username are tertiary.
[
{
"queryType": "query_string",
"occur": "should",
"operator": "and",
"fuzziness": "",
"boost": 2,
"fields": [
{
"fieldName": "title",
"localized": true,
"boost": 1.1,
"boostForLocalizedVersion": 1.2
},
{
"fieldName": "description",
"localized": true,
"boost": 1,
"boostForLocalizedVersion": 1.1
},
{
"fieldName": "content",
"localized": true,
"boost": 1,
"boostForLocalizedVersion": 1.1
}
]
},
{
"queryType": "query_string",
"occur": "should",
"operator": "or",
"fuzziness": "",
"boost": 1,
"fields": [
{
"fieldName": "title",
"localized": true,
"boost": 1.1,
"boostForLocalizedVersion": 1.1
},
{
"fieldName": "description",
"localized": true,
"boost": 1,
"boostForLocalizedVersion": 1.1
},
{
"fieldName": "content",
"localized": true,
"boost": 1,
"boostForLocalizedVersion": 1.1
}
]
},
{
"queryType": "wildcard",
"occur": "should",
"fieldName": "userName",
"boost": "0.5",
"keywordSplitter": " ",
"valuePrefix": "*",
"valueSuffix": "*"
}
]