Interface ModuleSearchRegistrationContext
- Since:
- 6.0.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns the current module name.registerSearchTemplate
(Supplier<SearchTemplate> aSearchTemplate) Registers a new search template supplier.registerStopWords
(StopWordsDeclaration aDeclaration, List<String> stopWords) Registers a new list of stop words under a given declaration.registerSynonyms
(SynonymDeclaration aDeclaration, List<SynonymPair> someSynonyms) Registers a new list of synonyms under a given declaration.
-
Method Details
-
getModuleName
String getModuleName()Returns the current module name. -
registerSearchTemplate
Registers a new search template supplier.Configure the template in the
Search
extension in the DMA.- Throws:
IllegalArgumentException
- if:- The specified search template declaration is
null
. - The specified search template declaration specifies a key that belongs to another module.
- The specified search template declaration does not specify
a
template
.
- The specified search template declaration is
- See Also:
-
registerStopWords
ModuleSearchRegistrationContext registerStopWords(StopWordsDeclaration aDeclaration, List<String> stopWords) Registers a new list of stop words under a given declaration.A field-level search strategy like 'Name' or 'Text' can be parameterized with a stop word list. All the words in the list are then ignored when searching. Tuning a search strategy with the appropriate stop words helps with performance and relevancy of the search.
Usage
Use the key in the declaration when configuring a custom field-level search strategy in the
Search
extension of the data model assistant. Then select a compatible field, and assign the new search strategy in the 'Extensions' tab.Code sample
In the implementation of
ModuleRegistration.handleSearchRegistration(ModuleSearchRegistrationContext)
:StopWordsDeclaration decl = StopWordsDeclaration.of( StopWordsKey.parse("myModuleName@stopWordsList"), UserMessage.createInfo("a label"), UserMessage.createInfo("a description")); aContext.registerStopWords(addressStopWordsDeclaration, Arrays.asList("sw1", "sw2"));
- Throws:
IllegalArgumentException
- if:- The specified stop word declaration is
null
. - The specified stop word declaration specifies a key that does not belong to any module.
- The specified stop word declaration specifies a key that belongs to another module.
- The specified stop word declaration is
-
registerSynonyms
ModuleSearchRegistrationContext registerSynonyms(SynonymDeclaration aDeclaration, List<SynonymPair> someSynonyms) Registers a new list of synonyms under a given declaration.A field-level search strategy like 'Name' or 'Text' can be parameterized with a synonyms list. Each pair of words in the list are then considered the same when searching.
Usage
Use the key in the declaration when configuring a custom field-level search strategy in the
Search
extension of the data model assistant. Then select a compatible field, and assign the new search strategy in the 'Extensions' tab.Code sample
The following sample declares 'Michael', 'Mike' and 'Mickael' as synonyms. Note that choosing the same word in the 'output' parameter of the
SynonymPair
allows 'Michael' to be considered as the synonym of 'Mickael' by transitivity. In the implementation ofModuleRegistration.handleSearchRegistration(ModuleSearchRegistrationContext)
:SynonymDeclaration decl = SynonymDeclaration.of(SynonymsKey.parse("myModuleName@synonymsList"), UserMessage.createInfo("a label"), UserMessage.createInfo("a description")); List
someSynonyms = Arrays.asList( SynonymPair.newPair("Michael", "Mike"), SynonymPair.newPair("Mickael", "Mike")); aContext.registerSynonyms(decl, someSynonyms); - Throws:
IllegalArgumentException
- if:- The specified synonym declaration is
null
. - The specified synonym declaration specifies a key that does not belong to any module.
- The specified synonym declaration specifies a key that belongs to another module.
- The specified synonym declaration is
-