Example:
http://stackoverflow.com/questions/5527868/exact-phrase-search-using-lucene
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
Comments
Post a Comment