We are using Graylog 4.2.3 on Debian 11.1 and use the API to query search and it work just fine. My problem is that I need to do a query in lucent that need quotation mark in lucene but I can’t figure out how to do it through the API
Web UI search I try to replicate via the API "2/2/2"
And it will output everything related to device with ID 2/2/2 but I need the quote else, lucene will ignore the slash and search every message that include 2 instead.
But the output is the same as if I search 2/2/2 in the GUI without quote. I tried several way to escape the quotation mark and try to pass it up to lucene but while capturing network traffic and looking back at pcap with wireshark. On those pcap, I was only able to see 2 POST send to the API: 2/2/2
that return every message that include a 2
or ""2/2/2""
that return an error.
I found this on StackOverflow that suggests escaping the forward slash and/or changing the query to be analyzed as keyword rather than token. Resulting in something similar to below…? (I am only using google-fu…this does NOT come from any prior knowledge)
"query_string": {
"type": "elasticsearch",
"query_string" : { <---- create this block
"query" : "2\/2\/2",
"analyzer": "keyword" <---- add this line
},
I already tried those and just tried it again. It work through the GUI but not through the API. The result is the same as “2 AND 2 AND 2” so I’m pretty sur the quote where remove again before hitting the API.
Yes, I read the stackoverflow post you shared and tried it after but sadly, it still return the same result as “2 AND 2 AND 2”. What seems to be missing is the "analyzer": "keyword" but the API return me that this option is unknow.
{"type":"ApiError","message":"Unable to map property analyzer.\nKnown properties include: query_string, type"}