I'm trying to return an OpenSearch Dashboards link within a JSON API. That should result in dashboards query that returns all documents within an index that contains an exact match of a value. Let me demonstrate using the following example:

// Query value 'abc '
// Document A
{
    "field_a": "abc"
}
// Document B
{
    "field_b": "abcd" 
}
// Document C
{
    "field_a": "ab"
}

I want my query to return documents A and B, but not C.

Essentially I can do that in OpenSearch Dashboards by wrapping my query value with double quotes - "abc". That however is a problem, when the link is contained within a JSON file, since it is then escaped to \"abc\". which is no longer considered as an exact-match query by the Dashboard. Thus in the above example, all files will probably be returned and some will have a lower _score.

I've been to the dql docs, but I didn't find anything there. Is there an alternative way of querying to get the data I need?

Constructing the OpenSearch Dashboard url itself is not an issue.

1

There are 1 best solutions below

0
On

OK, so it turns out that this is not an OpenSearch Dashboards problem, but encoding problem. There may be another way to query the information in OpenSearch Dashboards, but that is not necessary.

In short - urls are encoded to handle special characters. A list of encodings can be found here.

All I needed to do is replace my double quotes and their escape symbol with their encoding string. According to the table that is %22. From "abc" to %22abc%22.