How to use Lucene's own query syntax?

I read that Lucene has an internal query language that states: and you make combinations of them using logical operators. I read everything about it on my website and it works great in LUKE, I can do things like

field1:value1 AND field2:value2 

and he will return, apparently, the correct results.

My problem is how to pass this Lucene request to the API? I saw QueryParser, but I have to specify the field. Does this mean that I still have to manually parse my input string, fields, values, brackets, etc., Or is there a way to feed it all and let lucene do it?

I use Lucene.NET, but since this is a method through the port of the orignal java method, any advice is appreciated.

+4
source share
1 answer

You ask if you need to force the user to enter a field? If so, the query parser has a default field. Here is a little more detail . As long as you have a default field that will perform the task, they do not need to specify fields.

If you are asking how to get a Query object from a String , you will need a parse method. He understands the fields, the default field, etc., mentioned earlier. You just need to make sure that the query parser and index builder use the same analysis.

+2
source

All Articles