I’m trying to use Elasticsearch to index a city database and get autocomplete on a field.
Here is my FOSElasticaBundle configuration :
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
My query looks like this :
{
"query": {
"match": {
"name": "xxxxxx"
}
}
}
But my problem is here :
- When I type “Pa”, I get 242 results (ok)
- When I type “Par”, I get no results (WTF)
- When I type “Pari”, I get 22 results (ok)
- When I type “Paris”, I get 10 results (ok)
It’s my first time with Elasticsearch, I think the solution is nearby, but if somebody has the same issue, I’m curious to know more about it.
Thanks, have a good day ;)