Git Product home page Git Product logo

kirby3-typesense's Introduction

Kirby Typesense

This plugin allow you to index kirby pages into typesense and make fulltext search available for your website.

Overview

This plugin is free and under MIT license, I'm glad if you find it usefull. If you plan to use it for commercial use, or if I saved you some time, please consider helping me to maintain this by either making a donation of your choice or sponsoring me.

1. Install Typesense on your server

1.1 What is Typesense ?

Typesense is an opensource alternative for Algolia or ElasticSearch. It is free and provide a fast typo tolerant search engine.

1.2 Install Typesense

To use this plugin, you need to install Typesense on your server.


2. Install the Kirby Typesense plugin

Download and copy this repository to /site/plugins/typesense

Or even better, to get easy updates, install it with composer: composer require maxchene/kirby3-typesense


3. Configuration

Edit your config file: site/config/config.php to add your own plugin configuration.

Here is what it should look like:

'maxchene.typesense' => [
        'host' => 'localhost:8108', # typesense host and port
        'key' => 'secret', # typesense API key
        'num_typos' => 2, # number of allowed typo error
        'schema' => [
            'name' => 'my-collection',
            'fields' => [
                ['name' => 'content', 'type' => 'string'],
                ['name' => 'type', 'type' => 'string']
            ]
        ],
        'templates' => [
            'article' => function (Page $page) {

            },
            'default' => function (Page $page) {
                return [
                    'content' => 'text content that should be indexed for fulltext search',
                    'type' => 'default'
                ];
            }
        ]
    ]

3.1 Schema configuration

3.2 Templates configuration

4. Use fulltext search

All fields provided in the config file will be searched.

Param Description Type Optionnal Default value
$query your search string string no
$limit Maximum number of results per page integer yes 30
$page Page number integer yes 1

4.1 Site method

This plugins gives you access to the $site->typesenseSearch(string $query, int $limit, int $page) method wherever $site is available: templates, controllers,...


4.2 Typesense Search

You can also create a TypesenseSearch class :

 $searchEngine = new TypesenseSearch();
 $results =  $searchEngine->search($query, $limit, $page);

5. Command Line

6. Full configuration exemple

kirby3-typesense's People

Contributors

maxchene avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.