How to use a wild card query for both field and value in Lucene?

42 Views Asked by At

My problem is how to parse wildcard queries with Lucene for both field and value.

I'm storing a jsonObject as a canonical path in the lucene document. Example :

"field1":{
    "field2":{
       "field3":"test"}
     }
  }

It is stored as

field1.field2.field3 : test 

I'm using QueryParser with keywordAnalyser. My problem is that I want to use wildcard in field also.It is working fine for field's value. Example :

field1.field2.field3 : tes* is working fine but I want to use something like this field1.*.field3: tes* .

How can I achieve this?

Note: As an input I receive a query string, so building queries programmatically is not an option. Note: I'm using Lucene 8.11.2.

I cannot store * for field2 in the generated lucene document.

0

There are 0 best solutions below