I am facing an issue with querying a keyword that includes a dot (.) at the end. While the query works perfectly on Kibana's console, it fails to execute on my application's function. The following function is responsible for creating the query based on the provided keyword:
searchOperation(keyWord:String){
{
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": ["message"],
"query": keyWord + " AND \"DateID\""
}
}]
}}}}
An example of a keyword containing the problematic character is: "BAD.IJH.KLM"
To address this issue, I add an escape character ('\') before and after the quotation marks. This renders the keyword as \"BAD.IJH.KLM\", resulting in the following updated query:
{
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": ["message"],
"query": "\"BAD.IJH.KLM\" AND \"DateID\""
}
}]
}}}
However, it seems that the query is not searching for the exact keyword with dots but rather for the first substring within "BAD.IJH.KLM", which is 'BAD' in this case. How can I adjust my keyword/query to ensure that the search looks for the precise string with characters that are not reserved?