I'm trying out the search_as_you_type datatype instead of implementing a custom analyser for autosuggestions. My old solution worked when searching a text-field such as:
'text' => [
'type' => 'text',
'fields' => [
'suggest' => [
'type' => 'text',
'analyzer' => 'autosuggest',
'search_analyzer' => 'standard',
]
]
]
Where a document could be:
{
"_index": "someindex",
"_type": "_doc",
"_id": "1",
"_source": {
"text": [
"some text",
"other text"
],
"original_text": null,
"status": "good"
}
}
And the search query would a bool query containing:
bool: {
must: [
{
multi_match: {
query: "some",
fields: ['text.suggest^2', 'original_text.suggest'],
fuzziness: 'AUTO'
}
}
],
filter: [
terms: {
status: "good"
}
]
}
The text field can be either a string or an array of strings. When changing the text field mapping to:
'text' => [
'type' => 'search_as_you_type'
]
... and the query to:
bool: {
must: [
{
multi_match: {
query: "some",
fields: [
'text^10',
'text._index_prefix^2',
'original_text',
'original_text._index_prefix',
],
fuzziness: 'AUTO'
}
}
],
filter: [
terms: {
status: "good"
}
]
}
... i still get results where text is a single string, but documents where text is an array of strings don't show up. How come?