【发布时间】:2015-03-25 09:17:02
【问题描述】:
我正在尝试使用 Elasticsearch 来索引城市数据库并在字段上自动完成。
这是我的 FOSElasticaBundle 配置:
fos_elastica:
indexes:
xxxxxxx:
settings:
index:
analysis:
analyzer:
custom_analyzer:
type: custom
tokenizer: nGram
filter: [lowercase, asciifolding, stopwords_fr, elision, snowball_fr, word_delimiter]
custom_search_analyzer:
type: custom
tokenizer: standard
filter: [lowercase, asciifolding, stopwords_fr, elision, snowball_fr, word_delimiter]
tokenizer:
nGram:
type: nGram
min_gram: 4
max_gram: 20
filter:
snowball_fr:
type: snowball
language: French
elision:
type: elision
articles: [l, m, t, qu, n, s, j, d]
stopwords_fr:
type: stop
stopwords: [_french_]
ignore_case: true
types:
cities:
mappings:
id:
name: { search_analyzer: custom_analyzer, index_analyzer: custom_analyzer, type: string, store: yes }
persistence:
driver: orm
model: XXXXX\MainBundle\Entity\City
provider: { query_builder_method: createSearchIndexQueryBuilder }
listener: ~
finder: ~
repository: XXXXX\SearchBundle\Repository\CitySearchRepository
我的查询如下所示:
{
"query": {
"match": {
"name": "xxxxxx"
}
}
}
但我的问题就在这里:
- 当我输入 “Pa” 时,我得到 242 个结果(ok)
- 当我输入 “Par” 时,我得到 no results (WTF)
- 当我输入 “Pari” 时,我得到 22 个结果(ok)
- 当我输入 “Paris” 时,我得到 10 个结果(ok)
这是我第一次使用 Elasticsearch,我认为解决方案就在附近,但如果有人遇到同样的问题,我很想了解更多信息。
谢谢,祝你有美好的一天;)
【问题讨论】:
标签: symfony autocomplete elasticsearch foselasticabundle