I'm new to Lucene (literally just a second day of learning). I want to do a proximity search, for example, "hello" and "world" within 1 distance. I read https://lucene.apache.org/core/2_9_4/queryparsersyntax.html#Proximity%20Searches site and found out that I have to do "hello world"~1. So, what I tried were
QueryParser QP = new QueryParser("text", analyzer);
Query qry = QP.parse("hello world"~1);
this gave an error, so I did
QueryParser QP = new QueryParser("text", analyzer);
Query qry = QP.parse("hello world~1");
this did not give an error but did not give an answer I wanted. It returned a boolean search result that is simply any documents with "hello" and "world"
So, I printed qry and got text:hello text:world~1
not text:hello word~1
if my guess is right.
Can anyone help me how does a code for the proximity search should looks with the QueryParser?
Thank you!