PHP code example of intracto / elastic-synonym

1. Go to this page and download the library: Download intracto/elastic-synonym library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

intracto / elastic-synonym example snippets


'my_synonyms' => [ // a name for your filter
    'type' => 'synonym_graph',
    'synonyms_path' => 'analytics/synonyms.txt', // This needs to be the path inside /etc/elastic.
    'updateable' => true, // *must* be true
],

'default_search' => [
    // ..
    'filter' => [/*'..', */'my_synonyms'],
],

$body['query']['bool']['should'][] = ['match' => ['description' => [
    'query' => 'this is an example',
    'fuzziness' => 'AUTO',
    'operator' => 'OR',
]]];