Splitting texts inputs
You can split user inputs based on regular expressions, it will result on a multi value search.
Split user input to make a multi value search from fulltext inputs :
Search for ids from fulltext inputs :
This behavior is considered as bad practice. It is documented and present in basic config files for legacy purpose. Instead we recommend to create a specific filter to search on specific fields.
How to tune this behavior :
// /dam/explore/full-text-search.json
{
"regexId": "^#\\d+$",
"pattern": {
"regexps": ["\\d+"],
"separators": ",; ",
}
}
Â
By default splitted terms must all be present to match a result.
Meaning that searching for teapot copie will match teapot SOMETHING copie but not teapot or copie.
If you want a more google like experience, where your search for teapot copie will match teapot SOMETHING copie AND teapot AND copie.
You have to add an extra config key :
// /dam/explore/full-text-search.json
{
"regexId": "^#\\d+$",
"forceModeShouldOnPattern": true,
"pattern": {
"regexps": ["\\d+"],
"separators": ",; ",
}
}
Â
Â
Split user input to make a multi value search from advanced search text inputs :
How to tune this behavior :
// /dam/explore/advanced-filters/default-cursor-config/default-resource-config.json
[
{
"field": "name",
"i18nForEmpty": "advancedsearch.field.name.empty",
"i18nForNotEmpty": "advancedsearch.field.name.notempty",
"operators": [
"contains",
"startswith",
"endswith",
"notcontains",
"empty",
"notempty"
],
/**
* Patterns are regepx that you want use on the field to split the user input
* Example : for user input '1111111111111 2222222222222'
* The corresponding filter will be :
* Names contains '1111111111111' OR '2222222222222'
*
* The values contained in the "regexps" array correspond to one or several
* "named-patterns" (defined in : _portal/common/named-patterns)
* You can use your own regular expression.
*
*/
"pattern": {
"regexps": ["ean"]
}
},
{
"field": "description",
"i18nForEmpty": "advancedsearch.field.caption.empty",
"i18nForNotEmpty": "advancedsearch.field.caption.notempty",
"operators": [
"contains",
"startswith",
"endswith",
"notcontains",
"empty",
"notempty"
],
/**
* You can have more control on the provided pattern by adding values to the pattern entry.
*
* Note that you can add directly a custom regex ("\\d{2}").
* If you use it, you must escape the backslash !
*
* "flag" let you control how the pattern should behave.
* See : https://javascript.info/regexp-introduction#flags
*
* "separators" provides you a way to control which characters must be considered as separators
*
* Here : for user input '11-22 vv-666-yy'
* The corresponding filter will be :
* Description contains '11' OR '22' OR 'vv-666-yy'
*
* Note that the unmatching parts of the user input will be put together in another OR
*
* Example : for user input '11-22-777 vv-666-yy-999'
* The corresponding filter will be :
* Description contains '11' OR '22' OR 'vv-666-yy' OR '777 999'
*/
"pattern": {
"regexps": [ "immatriculation", "\\d{2}" ],
"separators": "-_",
"flag": "ig"
}
}
]
Â