blob: c2302d447de37e17e146bf95cec27de31bc403d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<?php
namespace Elastica\Query;
/**
* Class SimpleQueryString.
*
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html
*/
class SimpleQueryString extends AbstractQuery
{
const OPERATOR_AND = 'and';
const OPERATOR_OR = 'or';
/**
* @param string $query
* @param array $fields
*/
public function __construct($query, array $fields = array())
{
$this->setQuery($query);
if (sizeof($fields)) {
$this->setFields($fields);
}
}
/**
* Set the querystring for this query.
*
* @param string $query see ES documentation for querystring syntax
*
* @return $this
*/
public function setQuery($query)
{
return $this->setParam('query', $query);
}
/**
* @param string[] $fields the fields on which to perform this query. Defaults to index.query.default_field.
*
* @return $this
*/
public function setFields(array $fields)
{
return $this->setParam('fields', $fields);
}
/**
* Set the default operator to use if no explicit operator is defined in the query string.
*
* @param string $operator see OPERATOR_* constants for options
*
* @return $this
*/
public function setDefaultOperator($operator)
{
return $this->setParam('default_operator', $operator);
}
/**
* Set the analyzer used to analyze each term of the query.
*
* @param string $analyzer
*
* @return $this
*/
public function setAnalyzer($analyzer)
{
return $this->setParam('analyzer', $analyzer);
}
/**
* Set minimum_should_match option.
*
* @param int|string $minimumShouldMatch
*
* @return $this
*/
public function setMinimumShouldMatch($minimumShouldMatch)
{
return $this->setParam('minimum_should_match', $minimumShouldMatch);
}
}
|