I am trying to perform two Lucene queries. The first one works. The second does not. My first query looks like this:
level:"dangerous"
My second query looks like this:
IP address:"11.22.333.444"
I'm not getting a query error. However, I know there are documents with the matching IP address. For that reason, I suspect the space between "IP" and "address" is causing the problem. However, I'm not an expert in Lucene. So, I'm not sure if I'm correct in that.
When I look at my result set using PostMan, I can see a document with a field that looks like this:
"IP address": "11.22.333.444"
Can someone please tell me if my query is correct? Or, if I'm missing something?
Thank you!
Yes, that space is the problem.
The space in a field name is allowable, but conflicts with query parser syntax. You are essentially running two subqueries combined as SHOULD
clauses (ie, an OR
):
IP
address:"11.22.333.444"
You can escape the space using a single slash before the space, like:
IP\ address:"11.22.333.444"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With