Opensearch With Dynamic Object

Viewed 11

I need to perform a global search by free text. The documents, though, have a property “payload” which is an object type and its content is dynamic. This means that is not deterministic.

Is there a way to make a global search that basically treats the payload as a string? Sadly, changing the schema is not an option.

For example this document:

{
  description: 'This is an example',
  payload: {
      random_property: 'Hello world'
  }
}  

has to be found by typing: ‘Hello’ or ‘random_property’ or ‘this is an example’.

enter image description here

1 Answers

Our use case is in AWS; we stored new data directly from an event bus to opensearch and we didn't have control on data.

There is no way to convert an object to a string at the query time or to search free text within a nested object without specifying an exact path. At least, we haven't found any solution.

So we added a lambda between the event bus and opensearch for mapping new data where we can handle a new property "plain_payload" that convert the payload to a string.

Related