Elastica/FOSElastica がどのように機能しているかを理解しようとしています。製品名が検索文字列と完全に一致する、非常に単純な検索クエリのように、問題なく実行できました。
これは良い検索方法ではないため、より良い検索結果を実行するには、アナライザーを追加する必要があります。しかし、彼らは働いていません..
このサンプルコードをコピーして貼り付けようとしました(もちろん、インデックス/タイプを挿入しました)=> http://obtao.com/blog/2013/10/configure-elasticsearch-on-an-effective-way/#comment-16733
そこで、私の質問は次のとおりです。アナライザーを機能させるにはどうすればよいですか? コントローラーにそれらを適用する必要があると思いますが、それをどのように行うかは完全にはわかりません...
これは私の設定です
#app/config/config.yml
fos_elastica:
clients:
default: { host: localhost, port: 9200 }
indexes:
search:
client: default
settings:
index:
analysis:
analyzer:
custom_analyzer :
type : custom
tokenizer: nGram
filter : [stopwords, asciifolding ,lowercase, snowball, elision, worddelimiter]
custom_search_analyzer :
type : custom
tokenizer: standard
filter : [stopwords, asciifolding ,lowercase, snowball, elision, worddelimiter]
my_analyzer _:
type: snowball
language: German
tokenizer:
nGram:
type: nGram
min_gram: 2
max_gram: 20
filter:
snowball:
type: snowball
language: German
elision:
type: elision
articles: [l, m, t, qu, n, s, j, d]
stopwords:
type: stop
stopwords: [_german_]
ignore_case : true
worddelimiter :
type: word_delimiter
types:
article :
mappings:
articleNumber:
shortName: [ boost: 6, analyzer : custom_analyzer, custom_search_analyzer, my_analyzer]
shortDescription:
index_analyzer : custom_analyzer
search_analyzer : custom_search_analyzer
longDescription:
index_analyzer : custom_analyzer
search_analyzer : custom_search_analyzer
persistence:
driver: orm
model: IndexBundle\Entity\Articles
finder: ~
provider: ~
listener: ~
これは私のコントローラーです:
$query = new \Elastica\Query\Match();
$query->setFieldQuery(‘shortName’, $searchTerm);
$query->setFieldFuzziness(‘shortName’, 0.7);
$query->setFieldMinimumShouldMatch(‘shortName’, ’80%’);
$boolQuery = new \Elastica\Query\Bool();
$boolQuery->addMust($query);
$baseQuery = $query;
$filtered = new \Elastica\Query\Filtered($baseQuery);
$query = \Elastica\Query::create($filtered);
$articles = $finder->find($query);