0
到弹性搜索的一部分我很新的,也许你可以帮我:Elasticsearch和symfony的搜索词
所以,我有Symfony和Elasticsearch(FOSElasticaBundle)。
如果我在标题中搜索完整的单词 - 一切正常(例如,如果我输入“hello”,我将得到“hello”世界的结果)。
但问题是,是,我希望能够搜索词 的一部分也是如此,例如,如果我输入“HEL”我想要得到的结果,其中“HEL”一词的 一部分。
我config.yml
fos_elastica:
clients:
default: { host: localhost, port: 9200 }
indexes:
app:
client: default
settings:
index:
analysis:
analyzer:
custom_search_analyzer:
type: custom
tokenizer: standard
filter : [standard, lowercase, asciifolding]
custom_index_analyzer:
type: custom
tokenizer: standard
filter : [standard, lowercase, asciifolding, custom_filter]
filter:
custom_filter:
type: edgeNGram
side: front
min_gram: 1
max_gram: 20
types:
book:
mappings:
Author:
isbn:
title: { analyzer: custom_search_analyzer, analyzer: custom_index_analyzer, filter: custom_filter, type: string }
persistence:
driver: orm
model: VienasVienas\Bundle\BooksBundle\Entity\Book
provider:
listener:
finder:
我的PHP函数
public function indexAction(Request $request)
{
$finder = $this->get('fos_elastica.finder.app.book');
$searchTerm = $request->query->get('q');
$searchQuery = new \Elastica\Query\QueryString();
$searchQuery->setParam('query', $searchTerm);
$searchQuery->setDefaultOperator('AND');
$books = $finder->find($searchQuery);
return array(
'entities' => $books
);
}
谁能帮助?