New Subtitle
A html field with some content
Description
", + "media" => [3, 4], + ], + [ + "type" => "text", + "title" => "Title 2", + ], + [ + "type" => "embed", + "title" => "Video", + "media" => "https://www.youtube.com/watch?v=Ix6qBW4a1xg&t=826s", + ], + [ + "type" => "text", + "title" => "Title 4", + "description" => "Description 4
", + "media" => [3, 4], + ], + ], + ]; + + $documentB = [ + // ... + "header" => [ + "type": "video", + "title": "Title", + "media": "https://www.youtube.com/watch?v=Ix6qBW4a1xg&t=826s", + ], + "blocks" => [ + [ + "type" => "text", + "title" => "Title", + "description" => "Description
", + "media" => [3, 4], + ], + [ + "type" => "embed", + "title" => "Video", + "media" => "https://www.youtube.com/watch?v=Ix6qBW4a1xg&t=826s", + ], + ], + ]; + +The following field definitions will show us how we can use ``Typed`` fields to index the above fields +via ``multiple`` and define different types for it. + +.. code-block:: php + + new Field\TypedField('header', 'type', [ + 'image' => [ + 'title' => new Field\TextField('title'), + 'media' => new Field\IntegerField('media'), + ], + 'video' => [ + 'title' => new Field\TextField('title'), + 'media' => new Field\TextField('media', searchable: false), + ], + ]), + 'blocks' => new Field\TypedField('blocks', 'type', [ + 'text' => [ + 'title' => new Field\TextField('title'), + 'description' => new Field\TextField('description'), + 'media' => new Field\IntegerField('media', multiple: true), + ], + 'embed' => [ + 'title' => new Field\TextField('title'), + 'media' => new Field\TextField('media', searchable: false), + ], + ], multiple: true), + ]); + +**Options:** + ++-----------------+-----------------+ +| Name | Default | ++=================+=================+ +| ``multiple`` | ``false`` | ++-----------------+-----------------+ + +Create and Drop a Schema +------------------------ + +After you have defined your ``Schema`` with one or multple ``Indexes`` you need to create based on your used +integration the ``Indexes`` over the following way: + +.. tabs:: + + .. group-tab:: Standalone use + + When using the ``Standalone`` version you need to create the ``Indexes`` + in your search engines via the ``Engine`` instance which was created before: + + .. code-block:: php + + createSchema(); + + // create specific index + $engine->createIndex('blog'); + + .. group-tab:: Laravel + + To create the indexes in Laravel the following artisan command: + + .. code-block:: bash + + # create all indexes + php artisan schranz:search:index-create + + # create specific index + php artisan schranz:search:index-create --index=blog + + .. group-tab:: Symfony + + To create the indexes in Symfony the following console command: + + .. code-block:: bash + + # create all indexes + bin/console schranz:search:index-create + + # create specific index + bin/console schranz:search:index-create --index=blog + + .. group-tab:: Spiral + + To create the indexes in Spiral the following command: + + .. code-block:: bash + + # create all indexes + php app.php schranz:search:index-create + + # create specific index + php app.php schranz:search:index-create --index=blog + + .. group-tab:: Mezzio + + To create the indexes in Mezzio the following command: + + .. code-block:: bash + + # create all indexes + vendor/bin/laminas schranz:search:index-create + + # create specific index + vendor/bin/laminas schranz:search:index-create --index=blog + + .. group-tab:: Yii + + To create the indexes in Yii the following command: + + .. code-block:: bash + + # create all indexes + ./yii schranz:search:index-create + + # create specific index + ./yii schranz:search:index-create --index=blog + +To drop a ``Schema`` or an ``Index`` you can use the following: + +.. tabs:: + + .. group-tab:: Standalone use + + When using the ``Standalone`` version you need to drop the ``Indexes`` + in your search engines via the ``Engine`` instance which was created before: + + .. code-block:: php + + dropSchema(); + + // create specific index + $engine->dropIndex('blog'); + + .. group-tab:: Laravel + + To drop the indexes in Laravel the following artisan command: + + .. code-block:: bash + + # create all indexes + php artisan schranz:search:index-drop + + # create specific index + php artisan schranz:search:index-drop --index=blog + + .. group-tab:: Symfony + + To drop the indexes in Symfony the following console command: + + .. code-block:: bash + + # create all indexes + bin/console schranz:search:index-drop + + # create specific index + bin/console schranz:search:index-drop --index=blog + + .. group-tab:: Spiral + + To drop the indexes in Spiral the following command: + + .. code-block:: bash + + # create all indexes + php app.php schranz:search:index-drop + + # create specific index + php app.php schranz:search:index-drop --index=blog + + .. group-tab:: Mezzio + + To drop the indexes in Mezzio the following command: + + .. code-block:: bash + + # create all indexes + vendor/bin/laminas schranz:search:index-drop + + # create specific index + vendor/bin/laminas schranz:search:index-drop --index=blog + + .. group-tab:: Yii + + To drop the indexes in Yii the following command: + + .. code-block:: bash + + # create all indexes + ./yii schranz:search:index-drop + + # create specific index + ./yii schranz:search:index-drop --index=blog + +---------- + +Complex Example +--------------- + +A whole complex example ``Index`` with different types of ``Fields`` for documents like this: + +.. code-block:: php + + '23b30f01-d8fd-4dca-b36a-4710e360a965', + 'title' => 'New Blog', + 'header' => [ + 'type' => 'image', + 'media' => 1, + ], + 'article' => 'A html field with some content
Description
', + 'media' => [3, 4], + ], + [ + 'type' => 'text', + 'title' => 'Titel 2', + ], + [ + 'type' => 'embed', + 'title' => 'Video', + 'media' => 'https://www.youtube.com/watch?v=iYM2zFP3Zn0', + ], + [ + 'type' => 'text', + 'title' => 'Titel 4', + 'description' => 'Description 4
', + 'media' => [3, 4], + ], + ], + 'footer' => [ + 'title' => 'New Footer', + ], + 'created' => '2022-01-24T12:00:00+01:00', + 'commentsCount' => 2, + 'rating' => 3.5, + 'comments' => [ + [ + 'email' => 'admin.nonesearchablefield@localhost', + 'text' => 'Awesome blog!', + ], + [ + 'email' => 'example.nonesearchablefield@localhost', + 'text' => 'Like this blog!', + ], + ], + 'tags' => ['Tech', 'UI'], + 'categoryIds' => [1, 2], + ]; + + $documentB = [ + 'uuid' => '79848403-c1a1-4420-bcc2-06ed537e0d4d', + 'title' => 'Other Blog', + 'header' => [ + 'type' => 'video', + 'media' => 'https://www.youtube.com/watch?v=iYM2zFP3Zn0', + ], + 'article' => 'A html field with some content