Search Functionality

If you have a very large documentation it's very handy to have search function available so that your users can find their needs quickly.


Overview

LaRecipe support two different search engins: algolia, internal. The internal engin can be very userful if you have a private documentation since algolia DocSearch is free only for open-source projects.

However, the internal engine has limited power compared to algolia since it only index the titles of the pages and their headings.

Enable Search

You can enable search functionality simply by activating the enabled option inside config/larecipe.php file.

Once activated, the search button will appear at the top-right of the navbar. Also, you can trigger the search panel by typing s 😼

return [
    'search'            => [
        'enabled'       => false,
        ...
    ]
];

Available Engines

{primary.fa-search} Internal Engine

You can choose the internal search engine by assigning the default option to internal. You can also configure the indexable nodes so they will appear in the search results.

{warning} We highly recommend that you enable the cache when using internal search engin in order to get high performance and speed especially if you have very larg documentation. To enable the cache see the config.

return [
    'search'            => [
        'enabled'       => true,
        'default'       => 'internal',
        'engines'       => [
            'internal'  => [
                'index' => ['h2', 'h3']
            ],
            ...
        ]
    ]
]

{primary.fa-search} Algolia DocSearch Engine

Algolia DocSearch requires you to submit your site to them for indexing before it starts working.

For more information, refer to Algolia DocSearch's documentation

return [
    'search'            => [
        'enabled'       => true,
        'default'       => 'algolia',
        'engines'       => [
            ...
            'algolia'   => [
                'key'   => 'your_algolia_key',
                'index' => 'your_algolia_index'
            ]
        ]
    ]
];