1<?php
2
3namespace Elastica;
4
5/**
6 * Elastica searchable interface.
7 *
8 * @author Thibault Duplessis <thibault.duplessis@gmail.com>
9 */
10interface SearchableInterface
11{
12    /**
13     * Searches results for a query.
14     *
15     * {
16     *     "from" : 0,
17     *     "size" : 10,
18     *     "sort" : {
19     *          "postDate" : {"order" : "desc"},
20     *          "user" : { },
21     *          "_score" : { }
22     *      },
23     *      "query" : {
24     *          "term" : { "user" : "kimchy" }
25     *      }
26     * }
27     *
28     * @param string|array|\Elastica\Query $query   Array with all query data inside or a Elastica\Query object
29     * @param null                         $options
30     *
31     * @return \Elastica\ResultSet with all results inside
32     */
33    public function search($query = '', $options = null);
34
35    /**
36     * Counts results for a query.
37     *
38     * If no query is set, matchall query is created
39     *
40     * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
41     *
42     * @return int number of documents matching the query
43     */
44    public function count($query = '');
45
46    /**
47     * @param \Elastica\Query|string $query
48     * @param array                  $options
49     *
50     * @return \Elastica\Search
51     */
52    public function createSearch($query = '', $options = null);
53}
54