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\Dispatch;
4
5use CirrusSearch\Search\SearchQuery;
6
7/**
8 * For a given search engine entry point a SearchQueryRoute evaluates
9 * a particular SearchQuery and assign it a score.
10 * The SearchQueryDispatchService evaluates these scores and chose the best one
11 * in order to assign the profile context using the one provided by the route
12 * itself.
13 * SearchQueryRoutes are evaluated just after the SearchQuery is constructed
14 * and before ES query building components are chosen.
15 * @see \CirrusSearch\Profile\SearchProfileService
16 */
17interface SearchQueryRoute {
18    public const REJECT_ROUTE = 0.0;
19
20    /**
21     * Compute a score for this particular $query.
22     * Special values:
23     * - 0.0: this route must be avoided
24     * - 1.0: this route must supersede any others, the system
25     *      fails if multiple routes return a score equals to 1
26     * @param SearchQuery $query
27     * @return float a score between 0 and 1
28     */
29    public function score( SearchQuery $query );
30
31    /**
32     * The entry point used in the search engine:
33     * - searchText
34     * - nearMatch
35     * - completionSearch
36     *
37     * @return string
38     */
39    public function getSearchEngineEntryPoint();
40
41    /**
42     * The SearchProfile context to use when this route is chosen.
43     *
44     * @return string
45     */
46    public function getProfileContext();
47}