Nqxcode\LuceneSearch\Query\Builder::where PHP Метод

where() публичный Метод

Add where clause to the query for search by phrase.
public where ( string $field, mixed $value, array $options = [] )
$field string
$value mixed
$options array - field : field name - value : value to match - 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 where($field, $value, 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 testWhere()
 {
     $this->rawQueryBuilder->shouldReceive('build')->with($this->defaultWhereOptions())->andReturn(['test', true]);
     $query = $this->constructor->where('field', 'test');
     $this->assertEquals([1, 2, 3], $query->get());
     $this->assertEquals(3, $query->count());
 }