Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3namespace CirrusSearch\Fallbacks;
4
5use CirrusSearch\CirrusSearchHookRunner;
6use CirrusSearch\Parser\NamespacePrefixParser;
7use CirrusSearch\Search\CirrusSearchResultSet;
8use CirrusSearch\Search\SearchQuery;
9use CirrusSearch\Searcher;
10use Elastica\ResultSet as ElasicaResultSet;
11
12/**
13 * Context storing the states of the FallbackRunner.
14 * This object is populated/maintained by the FallbackRunner itself and read
15 * by the FallbackMethod.
16 */
17interface FallbackRunnerContext {
18
19    /**
20     * The initial resultset as returned by the main search query.
21     * @return CirrusSearchResultSet
22     */
23    public function getInitialResultSet(): CirrusSearchResultSet;
24
25    /**
26     * The resultset as rewritten by the previous fallback method.
27     * It may be equal to getInitialResultSet() if this is accessed by the
28     * first fallback method or if it was not rewritten yet.
29     * Technically this method returns the value of the previous FallbackMethod::rewrite()
30     * @return CirrusSearchResultSet
31     * @see FallbackMethod::rewrite()
32     */
33    public function getPreviousResultSet(): CirrusSearchResultSet;
34
35    /**
36     * Retrieve the response of the query attached to the main
37     * search request using ElasticSearchRequestFallbackMethod::getSearchRequest().
38     * NOTE: This method must not be called if no requests was attached.
39     *
40     * @return ElasicaResultSet
41     * @see ElasticSearchRequestFallbackMethod::getSearchRequest()
42     */
43    public function getMethodResponse(): ElasicaResultSet;
44
45    /**
46     * Whether or not a costly call is still allowed.
47     * @return bool
48     */
49    public function costlyCallAllowed();
50
51    /**
52     * Prepare a Searcher able to search for $rewrittenQuery.
53     * Calling this method.
54     * NOTE: a costly call must still be allowed before creating
55     * a new Searcher.
56     * @param \CirrusSearch\Search\SearchQuery $rewrittenQuery
57     * @return Searcher
58     * @see FallbackRunnerContext::costlyCallAllowed()
59     */
60    public function makeSearcher( SearchQuery $rewrittenQuery );
61
62    /**
63     * @return NamespacePrefixParser
64     */
65    public function getNamespacePrefixParser(): NamespacePrefixParser;
66
67    /**
68     * Whether or not this fallback method has an ElasticSearch response
69     * available.
70     * @return bool
71     */
72    public function hasMethodResponse();
73
74    /**
75     * @return CirrusSearchHookRunner
76     */
77    public function getCirrusSearchHookRunner(): CirrusSearchHookRunner;
78}