Should the parse method be configurable?

Created on 6 February 2024, 8 months ago

Problem/Motivation

The parse mode is being attached to the $query in a hard-coded way, using the 'terms' parse method with the default conjunction 'AND'. It is occurring at the highlighted lines here in IndexResource.php.

$parse_mode = $this->parseModeManager->createInstance('terms');
assert($parse_mode instanceof ParseModeInterface);
$query->setParseMode($parse_mode);

As a result, when performing a search with the terms "Navaho Sheep Herders", only documents that match all of these individual terms will be returned. While this behavior may be suitable for many projects, there are cases where search results are expected even if the documents match only one of the terms, such as "sheep" alone. This can be achieved by adjusting the parse mode to use the 'OR' operator as follows:

$parse_mode = $this->parseModeManager->createInstance('terms');
$parse_mode->setConjunction('OR');
assert($parse_mode instanceof ParseModeInterface);
$query->setParseMode($parse_mode);

I ended up patching the module to add the conjunction above in one of my projects.

This led to the following question:
Should the parse mode and its conjunction operator be configurable to provide greater flexibility in customizing the search behavior of this module?

Steps to reproduce

Just use the module out of the box and conduct a search with some multi-word value "Lorem Ipsum".

Proposed resolution

Provide a configuration page to allow developers to select the parse mode plugin and the conjunction operator.

Remaining tasks

Review this proposal and implement it.

User interface changes

A new configuration page will be created.

API changes

No API changes.

Data model changes

No data model changes.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇨🇴Colombia camilo.escobar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024