Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

According to the documentation example, the query highlighting settings will run incorrectly #38

Closed
iMactool opened this issue Apr 15, 2022 · 2 comments · Fixed by #41
Closed
Labels
bug Something isn't working

Comments

@iMactool
Copy link

iMactool commented Apr 15, 2022

My PHP : PHP 7.4.28 (cli)
use : tag/2.1.1

image

The error is as follows:

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function MacFJA\RediSearch\Redis\Command\Search::setHighlight(), 1 passed in /Code/redisearch-php/nindex.php on line 58 and exactly 3 expected in /Code/redisearch-php/vendor/macfja/redisearch/src/Redis/Command/Search.php:164
Stack trace:
#0 /Code/redisearch-php/nindex.php(58): MacFJA\RediSearch\Redis\Command\Search->setHighlight(Array)
#1 {main}
  thrown in /Code/redisearch-php/vendor/macfja/redisearch/src/Redis/Command/Search.php on line 164

The interface prototype is as follows
https://github.com/MacFJA/php-redisearch/blob/main/src/Redis/Command/Search.php

/**
     * @param null|array<string> $fields
     *
     * @return $this
     */
    public function setHighlight(?array $fields, ?string $openTag, ?string $closeTag): self
    {
        $this->options['highlight']
            ->setDataOfOption('type', true)
            ->setDataOfOption('fields', $fields)
            ->setTags($openTag, $closeTag)
        ;

        return $this;
    }

Correct execution should be

$search
    ->setIndex('person')
    ->setQuery('Doe')
     ->setHighlight(['lastname'],null,null)
    ->setWithScores();
$results = $client->execute($search);

So that I can execute successfully.

image

Documentation omissions ?

@MacFJA MacFJA added the bug Something isn't working label Apr 15, 2022
@MacFJA
Copy link
Owner

MacFJA commented Apr 15, 2022

Not an error in the documentation, it's rather an issue with the code.

The parameter #2 and #3 should be default to null, as the open and close tag are completely optional from the RediSearch documentation

@iMactool
Copy link
Author

ths

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants