Closed itmeicn closed 2 years ago
Hello,
You have 2 ways to set prefix(es), with the IndexBuilder
, or with the Create
command.
/** @var \MacFJA\RediSearch\Redis\Client $client */
$builder = (new \MacFJA\RediSearch\IndexBuilder())
->setIndex('idx')
->setPrefixes(['blog:post:']) // Setter take an array
->addTextField('title')
->addTextField('body');
$builder->create($client);
/** @var \MacFJA\RediSearch\Redis\Client $client */
$builder = (new \MacFJA\RediSearch\IndexBuilder())
->setIndex('idx')
->addPrefixes('blog:post:') // "Adder" take one or more arguments as prefixes
->addTextField('title')
->addTextField('body');
$builder->create($client);
/** @var \MacFJA\RediSearch\Redis\Client $client */
$create = (new \MacFJA\RediSearch\Redis\Command\Create())
->setIndex('idx')
->setPrefixes('blog:post:')
->addTextField('title')
->addTextField('body');
$client->execute($create);
I hope that answer your question.
thanks,I will. But I need more operations, such as CRUD. or detailed function description
This library is a "low-level" implementation. It reflect operation from RediSearch as close as possible.
If you want more high level I can suggest macfja/redisearch-integration (git).
This lib can offer method like persist
(C and U of CRUD), remove
(D of CRUD) and easier way to create a search (R of CRUD) on PHP object/class directly
But with only this library
C
and U
of CRUD\MacFJA\RediSearch\Index::addDocumentFromArray
will be the function to use
R
of CRUD\MacFJA\RediSearch\Redis\Command\Search
will be the object to create and to use with a Client
D
of CRUDYou will need to use other command or use \MacFJA\RediSearch\Redis\Client::executeRaw
($myClient->executeRaw('DEL', 'document_hash');
)
Thanks a lot, I will already use 2.x.
FT.CREATE idx ON HASH PREFIX 1 blog:post: SCHEMA,PREFIX ? how to use it create?