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\Query;
4
5use CirrusSearch\Parser\AST\KeywordFeatureNode;
6use CirrusSearch\Query\Builder\QueryBuildingContext;
7use Elastica\Query\AbstractQuery;
8
9/**
10 * A KeywordFeature that generates an elasticsearch query used
11 * as a filter.
12 * When a keyword implementation wants to filter a subset of docs matching a particular
13 * field/term it needs to implement this interface.
14 * This interface should only be implemented by KeywordFeature implementations.
15 * @see AbstractQuery
16 * @see KeywordFeature
17 */
18interface FilterQueryFeature {
19
20    /**
21     * Build a filter query using the information available in KeywordFeatureNode or in
22     * QueryBuildingContext::getKeywordExpandedData()
23     * This method will be called at the very end of the query generation process when building
24     * the query of the search request.
25     * The implementor may return null in case the parsed data is inappropriate
26     * it may help the query generation code to optimize the search process by not
27     * sending a search request to the backend (e.g. when this keyword is part of a
28     * conjunction at the root)
29     * @param KeywordFeatureNode $node the node corresponding to this keyword that was parsed
30     * @param QueryBuildingContext $context
31     * @return AbstractQuery|null the filter to apply or null if the information parsed
32     * in $node does not allow the query to be built.
33     * @see QueryBuildingContext::getKeywordExpandedData()
34     */
35    public function getFilterQuery( KeywordFeatureNode $node, QueryBuildingContext $context );
36}