PHP code example of kaliop / ezfindsearchenginebundle

1. Go to this page and download the library: Download kaliop/ezfindsearchenginebundle 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/ */

    

kaliop / ezfindsearchenginebundle example snippets


    ...

    ...

use eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder;
use Kaliop\EzFindSearchEngineBundle\API\Repository\Values\Content\Query\FacetBuilder as KaliopFacetBuilder;
 
$now = new DateTime();
$yearAgo = new DateTime();
$yearAgo->modify('-1 year');
 
$query->facetBuilders = [
    // Kaliop Facet Builders
    new KaliopFacetBuilder\FieldRangeFacetBuilder([
        'name' => 'Numeric field range facet',
        'fieldPath' => 'product/price',
        'start' => 100,
        'end' => 500,
        'gap' => 50,
        'limit' => 8,
    ]),
    new KaliopFacetBuilder\DateRangeFacetBuilder([
        'name' => 'Date range facet',
        'fieldPath' => 'article/publication_date',
        'start' => $yearAgo,
        'end' => $now,
        'gap' => new DateInterval('P1M'),
        'limit' => 12,
    ]),
    // Base eZ Facet Builders
    new FacetBuilder\FieldFacetBuilder([
        'name' => 'Simple field facet',
        'fieldPaths' => 'article/title',
        'limit' => 20,
    ]),
    new FacetBuilder\FieldFacetBuilder([
        'name' => 'Object relation(s) facet',
        'fieldPaths' => 'article/author/id',
        'limit' => 20,
    ]),
    new FacetBuilder\ContentTypeFacetBuilder([
        'name' => 'Content type facet',
    ]),
    new FacetBuilder\CriterionFacetBuilder([
        'name' => 'Criterion facet',
        'filter' => new Criterion\Field('article/title', Criterion\Operator::CONTAINS, 'new'),
    ]),
];