Skip to main content

Posts

Showing posts from April, 2015

illegal character in Netbeans

If it is Maven project.  Add following into the POM file.  <properties>         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>   </properties> Or right click project, select  "Properties  \ Sources \ Encoding" and change to UTF-8 For Netbeans supports UTF-8 in default. You have add following netbeans_default_options = "-J-Dfile.encoding=UTF-8" at a  netbeans.conf  file in you  netbeans installation\etc\ Reference: http://stackoverflow.com/questions/5034891/how-do-you-set-the-encoding-to-utf-8-in-netbeans-6-9

Exact phrase searching in Lucene

Example: DirectoryReader ireader = DirectoryReader . open ( mDir ); IndexSearcher isearcher = new IndexSearcher ( ireader ); QueryParser parser = new QueryParser ( Version . LUCENE_46 , myfieldname , analyzer ); parser . setDefaultOperator ( QueryParser . Operator . AND ); parser . setPhraseSlop ( 0 ); Query query = parser . createPhraseQuery ( myfieldname , keyword ); ScoreDoc [] hits = isearcher . search ( query , null , 1000 ). scoreDocs ; nret = hits . length ; ireader . close (); http://stackoverflow.com/questions/5527868/exact-phrase-search-using-lucene