Package COM. jadyer. lucene; import Java. io. file; import Java. io. ioexception; import Java. text. simpledateformat; import Java. util. date; import Org. apache. lucene. analysis. standard. standardanalyzer; import org.apache.e.doc ument. document; import org.apache.e.doc ument. field; import org.apache.e.doc ument. numericfield; import Org. apache. lucene. index. indexreader; import Org. apache. lucene. index. indexwri Ter; import Org. apache. lucene. index. indexwriterconfig; import Org. apache. lucene. queryparser. parseexception; import Org. apache. lucene. queryparser. queryparser; import Org. apache. lucene. search. indexsearcher; import Org. apache. lucene. search. query; import Org. apache. lucene. search. scoredoc; import Org. apache. lucene. search. topdocs; import Org. apache. lucene. store. directory; import Org. apache. lucene. store. fsdirecto Ry; import Org. apache. lucene. util. version; import COM. jadyer. custom. myqueryparser; /*** [lucene3.6.2 entry series] section 09th _ custom queryparser Advanced Search * @ create Aug 19,201 3 2:07:32 * @ author Xuan Yu
The following is the custom myqueryparser. Java (the following two functions are implemented here)
1) Disable fuzzy search and wildcard search to improve search performance
2) expanded search based on numbers and dates to support search by numbers and dates
Package COM. jadyer. custom; import Java. text. simpledateformat; import Java. util. regEx. pattern; import Org. apache. lucene. analysis. analyzer; import Org. apache. lucene. queryparser. parseexception; import Org. apache. lucene. queryparser. queryparser; import Org. apache. lucene. search. numericrangequery; import Org. apache. lucene. search. query; import Org. apache. lucene. util. version;/*** custom queryparser * @ see ------------ When * @ see actually uses queryparser, two problems are usually taken into account * @ see 1) queryparser with low performance restrictions -- for some queryparser, the performance will be reduced during search, so consider disabling these searches to improve performance * @ see 2) extended search based on numbers and dates-sometimes you need to perform a number range search, therefore, you need to extend the original queryparser to implement this search * @ see parser * @ see queryparser with low performance limit * @ see inheritance. Queryparser class and reload the corresponding method, such as getfuzzyquery and getwildcardquery * @ see. The result is that when a common search expression is input, for example, you can search for "I and Haerbin" * @ see "but enter" Name: jadk ~ 'Or 'name: Ja ?? Er, it will be executed to the overload method, then you can handle it yourself, for example, in this example, disabling this function * @ see parser * @ see extension for numeric and date-based queries * @ see is to inherit the queryparser class and then reload getrangequery () method * @ see and then perform special processing on the 'region' of numbers and dates (using numericrangequery. newintrange () method to search) * @ SEE Region * @ create Aug 6, 2013 4:13:42 pm * @ author