0

I'm trying to find a field with content including "Provided Hash [0" I'm using DQL on the OpenSearch Dashboard to attempt this query.

The field I'm searching on is called "message"

The values I'm parsing have many arbitrary characters before and after the part of the message I'm looking at. Of the two messages below I would like to return the first but not the second

Just some random text Provided Hash [0abcdef] then some more random text

Just some random text Provided Hash [1abcdef] then some more random text

I'm currently using the below query which is returning no results

message:"Provided Hash [0"

An example of a message which I'm expecting to get as a result would have the following in the message

Provided Hash [0abcdef]
1
  • is the following answer worked? Commented Apr 22 at 21:23

1 Answer 1

0

Reserved characters for DQL: \ ( ) : < > " *

Use a backslash (\) to escape reserved characters.

https://docs.opensearch.org/docs/latest/dashboards/dql/#reserved-characters

In your case you can try Provided Hash \\[0* query with out " at the beginning or end.

hint: If you add " your query " it will be a multi_match, without quote it will be a query_string query and you will see the results.

enter image description here

EDIT: If the above not works try with keyword field type.

enter image description here

EDIT 2:

Sample data:

PUT reserved_chars/_doc/1
{"text": "Just some random text Provided Hash [0abcdef] then some more random text"}

PUT reserved_chars/_doc/2
{"text": "Just some random text Provided Hash [1hdaslkh] then some more random text"}

DQL or DSL query search:

text.keyword : *Provided Hash [0abcdef]*

4
  • I initially tried escaping the [ without any luck. I think I should clarify there are also messages that do not have [0 should be excluded. Provided Hash [1hdaslkh] should not be returned in my results Commented Apr 18 at 15:13
  • added new comment above Commented Apr 18 at 15:37
  • Thanks for following up Musab! Still no luck. I'm sorry, I left out further information. The value I'm looking for is surrounded by more characters on either side any thing could be here Provided Hash [0cbas7912] anything could be here I've edited the original question to be more clear Commented 2 days ago
  • No worries. Thanks for more clarification. I updated my answer. Please test with the sample data and let me know the result Commented yesterday

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.