Issue
Environment
- Liferay DXP 7.4 U5+
- Liferay DXP Quarterly Releases
Resolution
- Text Match Over Multiple Fields element does not support empty searches, as it requires at least one keyword.
- To achieve the desired behavior, you should create a custom copy of this element and add a condition to its
JSONdefinition:
- Navigate to Global menu > Applications > Blueprints.
- Click on the Elements tab.
- Find the Text Match Over Multiple Fields element and make a copy (Actions button > Copy).
- Edit the copied element and give it a descriptive name (e.g., Custom Text Match Over Multiple Fields).
- In the
elementDefinitionsection, edit the JSON. -
Locate
queryEntriesand add the following condition block:"condition": { "not": { "equals": { "parameterName": "keywords", "value": "" } } }The final
queryEntriesblock should look similar to this:"queryEntries": [ { "clauses": [ { "context": "query", "occur": "must", "query": { "multi_match": { "fuzziness": "${configuration.fuzziness}", "query": "${keywords}", "minimum_should_match": "${configuration.minimum_should_match}", "boost": "${configuration.boost}", "fields": "${configuration.fields}", "type": "${configuration.type}", "operator": "${configuration.operator}", "slop": "${configuration.slop}" } } } ], "condition": { "not": { "equals": { "parameterName": "keywords", "value": "" } } } } ] - Save.
- Edit your Blueprint and add the Custom Text Match Over Multiple Fields element. Configure it with the same settings as the original.
- Remove/disable the original Text Match Over Multiple Fields element.
- Save the Blueprint.