Whole word search with elasticsearch


(Oleg S) #1

Just started wtih elasticsearch. And stuck with a question:
I have following strings in my es index:

"favourites", "favourites\a1"

If I try to search only first string with

'query' => [
    'match' => [
        'name' => 'favourites'
    ]
],

or

'filtered' => [
    'filter' => [
        'term' => [
            'name' => 'favourites'
        ],
    ]
]

It matchs both. How to solve it?


(Nik Everett) #2

Read about (mappings)[https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html] and (analyzers)[https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-analyzers.html]. The default mapping uses the default analyzer which will break words at punctuation-like-things.


(system) #3