1906 FIX search form autocomplete multi terms

This commit is contained in:
2022-08-15 16:57:57 +02:00
parent 1993f80d8d
commit db6a82f7f7
9 changed files with 29 additions and 19 deletions

View File

@@ -53,7 +53,7 @@ class Base extends ControllerBase {
$this->and_query->setParseMode($parse_mode);
// Set fulltext search keywords and fields.
if ($this->keys) {
$this->and_query->keys($this->keys);
$this->and_query->keys(implode(' ', $this->keys));
}
// in case of term id provided restrict the keys to taxo fields
@@ -166,7 +166,7 @@ class Base extends ControllerBase {
// Set fulltext search keywords and fields.
if ($this->keys) {
$this->or_query->keys($this->keys);
$this->or_query->keys(implode(' ', $this->keys));
}
// exclude results from and_query
@@ -176,7 +176,7 @@ class Base extends ControllerBase {
}
$this->or_query->addConditionGroup($exclude_and_results_conditions);
if (preg_match_all('/[WTRPCMFGSO]\d{4}/i', $this->keys, $matches)) {
if (preg_match_all('/[WTRPCMFGSO]\d{4}/i', implode(' ', $this->keys), $matches)) {
// in case we search for material references like W0117
$ref_conditions = $this->or_query->createConditionGroup('OR');
foreach ($matches[0] as $key => $value) {
@@ -264,8 +264,8 @@ class Base extends ControllerBase {
$this->keys = $request->query->get('keys');
if($this->keys){
$this->keys = mb_strtolower($this->keys);
// $this->keys = Tags::explode($this->keys);
\Drupal::logger('materio_sapi')->notice($this->keys);
$this->keys = Tags::explode($this->keys);
// \Drupal::logger('materio_sapi')->notice($this->keys);
}
// get the exacte term id in case of autocomplete
// $this->terms = $request->query->get('terms');
@@ -301,7 +301,7 @@ class Base extends ControllerBase {
$this->sapiQuery();
$resp['keys'] = $this->keys;
$resp['keys'] = json_encode($this->keys);
$resp['terms'] = json_encode($this->terms);
$resp['filters'] = $this->filters;
// $resp['count'] = $this->results->getResultCount();
@@ -313,7 +313,7 @@ class Base extends ControllerBase {
));
if ($this->keys) {
$resp['infos'] .= t(' keywords @keys', array(
"@keys" => $this->keys
"@keys" => implode(', ', $this->keys)
));
}
if ($this->keys && $this->filters) {
@@ -389,7 +389,7 @@ class Base extends ControllerBase {
];
if ($this->keys) {
$resp['#title'] = $this->keys;
$resp['#title'] = implode(', ', $this->keys);
// $this->sapiQuery();