We have Opensearch indexes with a flat_object field mapping. I’d like to be able to search for documents with certain words within this mapping
e.g. if the document is
PUT myindex/_doc/5
{
"header": {
"messageId": "5"
},
"payload": {
"error": {
"field1": "field1value",
"field2": "words i'd like to be able to search on"
}
}
}
and the “payload” field is a flat_object
the following query finds the document
get myindex/_search
{
"query": {
"match": {
"header.messageId": 5
}
}
}
the following query finds the document
GET myindex/_search
{
"query": {
"match": {
"payload": "field1value"
}
}
}
the following query finds the document
GET myindex/_search
{
"query": {
"match": {
"payload": "words i'd like to be able to search on"
}
}
}
the following query finds nothing
GET myindex/_search
{
"query": {
"match": {
"payload": "search"
}
}
}
I can only find the document using field2 if i exactly match the string, what’s the best way to enable searching for words within the string ?