Skip to content
Snippets Groups Projects
Commit db195394 authored by Sebastien ANDRE's avatar Sebastien ANDRE
Browse files

fix failure advanced search

parent b570b70a
No related merge requests found
Pipeline #34243 canceled with stage
in 7 seconds
This commit is part of merge request !4999. Comments created here will be created in the context of that merge request.
......@@ -165,24 +165,29 @@ class Class_CriteresRecherche_AxeParamBlock
Storm_Query_Criteria $criteria): self
{
$match = (new Storm_Query_MatchBoolean($field));
$or_matchs = new Storm_Collection;
foreach ($values as $value) {
$or_terms = new Storm_Collection;
$this->_terms
->analyse($value);
$this->_terms->analyse($value);
$pertinence = $this->_pertinence || 1 === $this->_terms->wordsCount();
$callback = ($this->_pertinence || 1 === $this->_terms->wordsCount())
$callback = $pertinence
? fn($variants) => $or_terms->addAll($variants)
: fn($variants) => $or_terms->add(Storm_Query_Terms::and($variants));
$this->_terms
->withVariantsDo($callback)
->withExactWordsDo(fn($words) => $or_terms
->add(Storm_Query_Terms::orExact($words)));
->withExactWordsDo(fn($words) => $or_terms->add(Storm_Query_Terms::andExact($words)));
if ($pertinence)
$or_matchs->addAll($or_terms->getArrayCopy());
$match->against_or($or_terms->getArrayCopy());
if ( ! $pertinence)
$or_matchs->add(Storm_Query_Terms::and($or_terms->getArrayCopy()));
}
$match->against_or($or_matchs->getArrayCopy());
$this->_applyMatchTo($match, $criteria);
return $this;
......
......@@ -101,8 +101,8 @@ class Class_MoteurRecherche_MatchAxes
});
$this->_matchAllAxes()
->against_and(array_merge($match_terms,
[Storm_Query_Terms::or([$this->_or_domain])]));
->against_and(Storm_Query_Terms::or([Storm_Query_Terms::and($match_terms),
$this->_or_domain]));
return $this;
}
......
Subproject commit 81a52aeab6e0cb01a2f604f9687032e0ff93fe6f
Subproject commit b78b5dbe1d0a87ba5b4b43b9e8cba37df6aae700
......@@ -185,19 +185,19 @@ class AdvancedSearchResultAxesToSqlTest extends AbstractControllerTestCase {
"SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_HTHES0001' IN BOOLEAN MODE) OR MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_HTHES012T F_HTHES00SJ)' IN BOOLEAN MODE)) AND `notices`.`type` = 1)"],
['a10%22Jardins%22', // title with exact expression
"SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('\"JARDINS\"' IN BOOLEAN MODE) AND `notices`.`type` = 1)"],
"SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('+\"JARDINS\"' IN BOOLEAN MODE) AND `notices`.`type` = 1)"],
['a12%22bien+commun%22-12%22biens+communs%22',
"SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`matieres`) AGAINST('\"BIEN COMMUN\" \"BIENS COMMUNS\"' IN BOOLEAN MODE) AND `notices`.`type` = 1)"],
"SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`matieres`) AGAINST('(+\"BIEN COMMUN\") (+\"BIENS COMMUNS\")' IN BOOLEAN MODE) AND `notices`.`type` = 1)"],
['a10bien+commun-10oeuvre+litéraire',
"SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('(+(BIEN BIENS BIN) +(COMMUN COMMUNS KOMIN)) (+(OEUVRE OEUVRES EVR) +(LITERAIRE LITERAIRES LITERAIR))' IN BOOLEAN MODE) AND `notices`.`type` = 1)"],
['a12%22bien+commun%22~a12%22biens+communs%22',
"SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((MATCH(`notices`.`matieres`) AGAINST('\"BIEN COMMUN\"' IN BOOLEAN MODE) AND MATCH(`notices`.`matieres`) AGAINST('\"BIENS COMMUNS\"' IN BOOLEAN MODE)) AND `notices`.`type` = 1)"],
"SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((MATCH(`notices`.`matieres`) AGAINST('+\"BIEN COMMUN\"' IN BOOLEAN MODE) AND MATCH(`notices`.`matieres`) AGAINST('+\"BIENS COMMUNS\"' IN BOOLEAN MODE)) AND `notices`.`type` = 1)"],
['a10renard+poisson',
"SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('(+(RENARD RENARDS RENAR) +(POISSON POISSONS POISON))' IN BOOLEAN MODE) AND `notices`.`type` = 1)"],
"SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('+(RENARD RENARDS RENAR) +(POISSON POISSONS POISON)' IN BOOLEAN MODE) AND `notices`.`type` = 1)"],
['a10bois-10escaliers',
"SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('BOI BOIS ESCALIER ESCALIERS ESKALI' IN BOOLEAN MODE) AND `notices`.`type` = 1)"]
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment