Based on this answer (the first option) I've created this index:
'settings' => array(
'analysis' => array(
'analyzer' => array(
'stop_analyzer' => array(
'type' => 'custom',
'tokenizer' => 'standard',
'filter' => array(
'lowercase',
'english_stop'
)
)
),
"filter" => array(
"english_stop" => array(
"type" => "stop",
"stopwords" => "_english_"
)
)
)
),
'mappings' => array(
'properties' => array(
'texts' => array(
'type' => 'completion',
"analyzer" => "stop_analyzer",
"search_analyzer" => "stop_analyzer",
'preserve_position_increments' => false
),
),
)
This works perfect when I begin the suggest search with or without a stop word. However, when for example I have this in my index: This is the text
, and I search for text
I won't get any results, so what's the proper way to do this? I'd rather not use N-gram.
My search query:
'suggest' => array(
'suggestion' => array(
'prefix'=> 'text',
'completion' => array(
'field' => 'texts'
)
)
)
Adding a working example with index mapping, index data, search query, and search result
Index Mapping:
Analyze API
The following tokens are generated:
Index Data:
Search Query:
Search Result: