cakephp / elastic-search

Elastic search datasource for CakePHP
Other
88 stars 53 forks source link

Can't use \Elastica\Query::setMinScore in \Cake\ElasticSearch\Query #128

Closed maimai-swap closed 7 years ago

maimai-swap commented 7 years ago

I want to filter result by score.

lorenzo commented 7 years ago

What branch of this plugin are you using?

maimai-swap commented 7 years ago

Thank you for your reply! I use this. composer.lock

"name": "cakephp/elastic-search",
            "version": "0.3.4",
            "source": {
                "type": "git",
                "url": "https://github.com/cakephp/elastic-search.git",
                "reference": "e96022cefdfda37701dcd2d49e8326b27aecb00b"
            },

I read the source of \Cake\ElasticSearch\Query::compileQuery.

I wished good I could set minscore like this..


    /**
     * Compile the Elasticsearch query.
     *
     * @return string The Elasticsearch query.
     */
    public function compileQuery()
    {
        if($this->_options["min_score"]) {
            $this->_elasticQuery->setMinScore("min_score",$this->_options["min_score"]);
        }
        // snip...
``
lorenzo commented 7 years ago

The ability to add min score was added in branch 1.0. I would suggest using that branch instead. The method name is called withMinScore()