Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
icarojerry committed Jan 20, 2021
1 parent 20c8135 commit 3ef9367
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/Vespa/Common/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ public static function removeExtraSpace(string $text) : string
return trim(preg_replace("/\s+/", '${1} ', $text));
}

public static function removeSpecialCharacters(string $text) : string
public static function removeSpecialCharacters(string $text, $replacement = '') : string
{
$text = str_replace("°", "", $text);
$text = str_replace("ª", "", $text);
$text = str_replace("º", "", $text);
return preg_replace('/[#$%^&*@()+=\-\[\]\';,.\/{}|":<>?~\\\\]/', '${1} ', $text);
return trim(preg_replace('/[\x00-\x1F\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\xBF\xC5\xC6\xD0\xD7\xD8\xDE\xDF\xE5\xE6\xF0\xF7\xF8\x{00FE}-\x{FFFF}]/u', $replacement, $text));
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Vespa/Models/VespaQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ public function __construct(AbstractClient $client)
$this->parent_client = $client;
}

public final function get() : VespaResult
public final function get(bool $reset = true) : VespaResult
{
$payload = $this->toArray();
$this->reset();
if ($reset) {
$this->reset();
}
return $this->parent_client->search($payload);
}

Expand Down
6 changes: 5 additions & 1 deletion src/Vespa/Models/VespaYQLBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public final function reset() : VespaYQLBuilder
return $this;
}

public final function hasWhereConditions() : string
{
return !empty($this->search_condition_groups);
}

public function addStemmingCondition(string $term, bool $stemming = false, string $field = 'default', $operator = 'CONTAINS', $logical_operator = 'AND', $group_name = null) : VespaYQLBuilder
{
$term = Utils::removeQuotes($term);
Expand All @@ -55,7 +60,6 @@ public function addStemmingCondition(string $term, bool $stemming = false, strin

public function addWandCondition(string $term, string $field = 'default', $logical_operator = 'AND', $group_name = null, int $target_num_hits = null, float $score_threshold = null, \Closure $weight_tokens = null) : VespaYQLBuilder
{
$tokens = $this->splitTerm($term);
[$tokens, $not_tokens] = $this->tokenizeTerm($term, true);
$tokens = $this->generateWeightedTokens($tokens);
if($weight_tokens != null)
Expand Down

0 comments on commit 3ef9367

Please sign in to comment.