Elasticsearch未返回部分结果

时间:2016-05-10 08:46:33

标签: php laravel elasticsearch laravel-5.1

我正在使用Laravel 5.1mustafaaloko/elasticquent5包(found here)。

但是在尝试返回结果时,我只能在搜索确切的单词时获得结果。如果我尝试搜索部分单词,则不返回任何内容。

我正在使用Profile::addAllToIndex();dd(Profile::search(Input::get('search_term')));

我的配置如下:

<?php

return array(

    /*
    |--------------------------------------------------------------------------
    | Custom Elasticsearch Client Configuration
    |--------------------------------------------------------------------------
    |
    | This array will be passed to the Elasticsearch client.
    | See configuration options here:
    |
    | http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/_configuration.html
    */

    'config' => [
        'hosts'     => ['ahp.dev:9200'],
        'logging'   => true,
        'logPath'   => storage_path() . '/logs/elasticsearch.log',
        'logLevel'  => Monolog\Logger::WARNING,
    ],

    /*
    |--------------------------------------------------------------------------
    | Default Index Name
    |--------------------------------------------------------------------------
    |
    | This is the index name that Elastiquent will use for all
    | Elastiquent models.
    */

    'default_index' => 'default',

);

1 个答案:

答案 0 :(得分:1)

您应该尝试使用searchByQuery代替search并使用query_string查询

Profile::searchByQuery(array('query_string' => array('query' => Input::get('search_term'))));