我正在使用Laravel 5.1
和mustafaaloko/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',
);
答案 0 :(得分:1)
您应该尝试使用searchByQuery
代替search
并使用query_string
查询
Profile::searchByQuery(array('query_string' => array('query' => Input::get('search_term'))));