Skip to content

Commit

Permalink
Improved PostgreSQL multi term query
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Jan 2, 2021
1 parent d86984b commit b53c230
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/mshoplib/src/MShop/Index/Manager/Text/PgSQL.php
Expand Up @@ -23,15 +23,15 @@ class PgSQL
private $searchConfig = array(
'index.text:relevance' => array(
'code' => 'index.text:relevance()',
'internalcode' => ':site AND mindte."langid" = $1 AND CAST( to_tsvector(\'english\', mindte."content") @@ to_tsquery( $2 ) AS integer )',
'internalcode' => ':site AND mindte."langid" = $1 AND CAST( to_tsvector(mindte."content") @@ to_tsquery( $2 ) AS integer )',
'label' => 'Product texts, parameter(<language ID>,<search term>)',
'type' => 'float',
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
'public' => false,
),
'sort:index.text:relevance' => array(
'code' => 'sort:index.text:relevance()',
'internalcode' => 'ts_rank(to_tsvector(\'english\', mindte."content"), to_tsquery( $2 ))',
'internalcode' => 'ts_rank(to_tsvector(mindte."content"), to_tsquery( $2 ))',
'label' => 'Product text sorting, parameter(<language ID>,<search term>)',
'type' => 'float',
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
Expand All @@ -55,7 +55,7 @@ public function __construct( \Aimeos\MShop\Context\Item\Iface $context )
$name = 'index.text:relevance';
$expr = $this->getSiteString( 'mindte."siteid"', $level );
$this->searchConfig[$name]['internalcode'] = str_replace( ':site', $expr, $this->searchConfig[$name]['internalcode'] );
$this->searchConfig[$name]['function'] = $this->getFunctionRelevance();
$this->searchConfig[$name]['function'] = $this->searchConfig['sort:' . $name]['function'] = $this->getFunctionRelevance();
}


Expand Down Expand Up @@ -99,7 +99,7 @@ protected function getFunctionRelevance()
}
}

$params[1] = '\'' . join( ' & ', $strings ) . '\'';
$params[1] = join( ' | ', $strings ) . ' | "' . join( ' <-> ', explode( ' ', $search ) ) . '"';
}

return $params;
Expand Down

0 comments on commit b53c230

Please sign in to comment.