As you have not mentioned your mapping, I created my own mapping according to your data and indexed your sample docs and it works fine.
You can also check how your data is indexed using the _analyze API, which would help you debug the issue efficiently. Also, use explain API which would tell you why your should clause is not matching any doc.
Index def
{
"mappings": {
"properties": {
"a": {
"type": "text"
},
"b": {
"type": "integer"
}
}
}
}
Index sample docs
{
a : "status",
b : "01"
},
{
a : "status b",
b : "02"
}
Note search query is also same as yours
{
"query": {
"bool": {
"must": [
{
"match": {
"a": "status b"
}
}
],
"should": [
{
"match": {
"b": "01"
}
}
]
}
}
}
And it bring both the sample docs
"hits": [
{
"_index": "so_must_should",
"_type": "_doc",
"_id": "1",
"_score": 1.2111092,
"_source": {
"a": "status",
"b": "01"
}
},
{
"_index": "so_must_should",
"_type": "_doc",
"_id": "2",
"_score": 0.77041256,
"_source": {
"a": "status b",
"b": "02"
}
}
]
Please cross-check your mapping and compare it with this sample and let me know if you have further questions.