I'd like let the Elasticsearch retu the result of the search keyword including space like "bread " correctly. I'm attaching the screenshot of my current result. 
The result what I expected is not supposed to be included the "Breadcrumb" and "Breadfruit" since it hasn't "bread" keyword but has prefix.
My searching query like as below,
{
"query":{
"bool":{
"should": [
{
"match_phrase_prefix": {
"keyword": {
"query":"bread ",
"boost": 30
}
}
},
{
"term": {
"keyword": {
"value": "bread ",
"boost": 40
}
}
},
{
"match_phrase_prefix": {
"keyword_singluar": {
"query":"bread ",
"boost": 25
}
}
},
{
"term": {
"keyword_singluar": {
"value": "bread ",
"boost": 35
}
}
}
]
}
},
"sort": [
{ "_score": { "order": "desc" }},
{
"_script": {
"script": "doc['keyword'].value.length()",
"type": "number",
"order": "asc"
}
},
{ "keyword": { "order": "asc" }},
{ "keyword_singluar": { "order": "asc" }}
]
}
}
And my mapping configuration like as below:
index_body['settings'] = {
'number_of_shards': num_shards,
'number_of_replicas': num_replicas,
'index':{
'analysis':{
'analyzer':{
'analyzer_startwith':{
'tokenizer':'keyword',
'filter':'lowercase',
"stopwords": ("_%s_"%language)
}
}
}
}
}
index_body['mappings'] = dict(
keyword=dict(_id=dict(path='index_id'),
properties=dict(index_id=dict(type='long', index='not_analyzed'),
keyword_id=dict(type='long', index='not_analyzed'),
keyword=dict(type='string', search_analyzer='analyzer_startwith',
index_analyzer='analyzer_startwith'),
keyword_singluar=dict(type='string', analyzer='standard'))
)
)
Do you guys have any idea about this problem?
