Nqxcode\LuceneSearch\Query\Builder::query PHP Method

query() public method

Add a basic search clause to the query.
public query ( $value, $field = '*', array $options = [] )
$value
$field
$options array - required : should match (boolean, true by default) - prohibited : should not match (boolean, false by default) - phrase : phrase match (boolean, true by default) - proximity : value of distance between words (unsigned integer) - fuzzy : value of fuzzy(float, 0 ... 1)
    public function query($value, $field = '*', array $options = [])
    {
        $options['field'] = $field;
        $options['value'] = $value;
        $options = $this->defaultOptions($options);
        $this->query = $this->addSubquery($this->query, $options);
        return $this;
    }

Usage Example

 public function testPaginate()
 {
     $models = m::mock(LazyCollection::make([]));
     $models->shouldReceive('slice')->with(0, 2)->andReturn($sliced = m::mock(LazyCollection::make([])));
     $sliced->shouldReceive('reload')->andReturn(Collection::make([1, 2]));
     $query = $this->constructor->query('test');
     $this->runner->shouldReceive('models')->with($this->query)->andReturn($models);
     $expected = new Paginator([1, 2], 3, 2);
     $actual = $query->paginate(2);
     $this->assertEquals($expected, $actual);
     $models->shouldReceive('slice')->with(2, 2)->andReturn($sliced);
     $this->runner->shouldReceive('models')->with($this->query)->andReturn($models);
     $actual = $query->paginate(2, 2);
     $this->assertEquals($expected, $actual);
 }
All Usage Examples Of Nqxcode\LuceneSearch\Query\Builder::query