- ``foo OR bar``
- ``title:foo`` searches for ``foo`` only in the page title
- Facets for tag, domain, language and type
+- Date search:
+
+ - ``before:2016-08-30`` - modification date before that day
+ - ``after:2016-08-30`` - modified after that day
+ - ``date::2016-08-30`` - exact modification day match
- Site search
- Query: ``foo bar site:example.org/dir/``
);
}
+ $qMust = array();//query parts for the MUST section
+
+ //modification date filters
+ if (preg_match('#after:([^ ]+)#', $query, $matches)) {
+ $dateAfter = $matches[1];
+ $query = trim(str_replace($matches[0], '', $query));
+ $qMust[] = array(
+ 'range' => array(
+ 'modate' => array(
+ 'gt' => $dateAfter . '||/d',
+ )
+ )
+ );
+ }
+ if (preg_match('#before:([^ ]+)#', $query, $matches)) {
+ $dateBefore = $matches[1];
+ $query = trim(str_replace($matches[0], '', $query));
+ $qMust[] = array(
+ 'range' => array(
+ 'modate' => array(
+ 'lt' => $dateBefore . '||/d',
+ )
+ )
+ );
+ }
+ if (preg_match('#date:([^ ]+)#', $query, $matches)) {
+ $dateExact = $matches[1];
+ $query = trim(str_replace($matches[0], '', $query));
+ $qMust[] = array(
+ 'range' => array(
+ 'modate' => array(
+ 'gte' => $dateExact . '||/d',
+ 'lte' => $dateExact . '||/d',
+ )
+ )
+ );
+ }
+
+ $qMust[] = array(
+ 'query_string' => array(
+ 'default_field' => '_all',
+ 'default_operator' => 'AND',
+ 'query' => $query
+ )
+ );
+ $qMust[] = array(
+ 'term' => array(
+ 'status' => 'indexed'
+ )
+ );
+
if ($sort == 'date') {
$sortCfg = array('modate' => array('order' => 'desc'));
} else {
),
'query' => array(
'bool' => array(
- 'must' => array(
- array(
- 'query_string' => array(
- 'default_field' => '_all',
- 'default_operator' => 'AND',
- 'query' => $query
- )
- ),
- array(
- 'term' => array(
- 'status' => 'indexed'
- )
- ),
- )
+ 'must' => $qMust
)
),
'highlight' => array(