PHP code example of makinacorpus / php-lucene

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

    

makinacorpus / php-lucene example snippets


use MakinaCorpus\Lucene\Query;

$query = new Query();

$query
    ->createTermCollection(Query::OP_OR)
    ->add("foo")
    ->add("bar")
;

$query
    ->createDateRange()
    ->setInclusive()
    ->setRange('1983-03-22', new \DateTime())
;

$query
    ->matchTerm('some_field', 'some value', null, 0.8)
    ->matchTerm('other_field', 'some_other_value', 1.3)
;
lucene
(
    (foo OR bar)
    AND my_date_field:["1983\-03\-22T00\:00\:00\+0000" TO "2016\-06\-29T13\:10\:20\+0000"]
    AND some_field:"some value"~0.8
    AND other_field:some_other_value^1.3
)