java - Regexp Query in Lucene -
i working lucene search, having list of names like
1) city of cairo 2) calicut official branch 3) cairo branch office
if user types "co", have bring names start "c" , sec word should start "o", should homecoming 1st name(city of cairo) , 2nd name (calicut official branch). 3rd name(cairo branch office) name should not returned, not having second word started "o". using regexpquery query. listing above 3 names wrong.
regexpquery dynamicregex3 = new regexpquery(new term("name", "c.* o.*"));
what way accomplish ?
printed query :::: name:/c.* o.*/
your regex greedy, utilize instead:
regexpquery dynamicregex3 = new regexpquery(new term("name", "c[^ ]* o.*"));
[^ ]
stands character not space.
java regex lucene
No comments:
Post a Comment