Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
LtrQuery
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 6
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 _getBaseName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setModel
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 setStore
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 addLtrParam
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 setLtrParams
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Implementation of "sltr" query from ltr-query plugin
4 *
5 * @link https://github.com/o19s/elasticsearch-learning-to-rank
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
21 */
22
23namespace CirrusSearch\Elastica;
24
25use Elastica\Query\AbstractQuery;
26
27class LtrQuery extends AbstractQuery {
28    /**
29     * @param string $model The stored model to use
30     * @param string[] $params map of string -> string containing templating
31     *  parameters for ltr features.
32     */
33    public function __construct( $model, array $params ) {
34        $this->setModel( $model )
35            ->setLtrParams( $params );
36    }
37
38    /**
39     * @return string
40     */
41    protected function _getBaseName() {
42        return "sltr";
43    }
44
45    /**
46     * The stored model to use.
47     *
48     * @param string $model
49     * @return self
50     */
51    public function setModel( $model ) {
52        $this->setParam( 'model', $model );
53
54        return $this;
55    }
56
57    /**
58     * The name of the feature store to find the model in.
59     *
60     * @param string $store
61     * @return self
62     */
63    public function setStore( $store ) {
64        $this->setParam( 'store', $store );
65
66        return $this;
67    }
68
69    /**
70     * Add a parameter used for templated features
71     *
72     * @param string $key
73     * @param string $value
74     * @return self
75     */
76    public function addLtrParam( $key, $value ) {
77        $this->_params['params'][$key] = $value;
78
79        return $this;
80    }
81
82    /**
83     * Set all parameters used for templated features.
84     *
85     * @param string[] $params map of string -> string containing templating
86     *  parameters for ltr features.
87     * @return self
88     */
89    public function setLtrParams( array $params ) {
90        $this->setParam( 'params', $params );
91
92        return $this;
93    }
94}