本文整理匯總了Java中org.apache.lucene.util.Version.LUCENE_44屬性的典型用法代碼示例。如果您正苦於以下問題:Java Version.LUCENE_44屬性的具體用法?Java Version.LUCENE_44怎麽用?Java Version.LUCENE_44使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.lucene.util.Version
的用法示例。
在下文中一共展示了Version.LUCENE_44屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: FbEntitySearcher
public FbEntitySearcher(String indexDir, int numOfDocs, String searchingStrategy) throws IOException {
LogInfo.begin_track("Constructing Searcher");
if (!searchingStrategy.equals("exact") && !searchingStrategy.equals("inexact"))
throw new RuntimeException("Bad searching strategy: " + searchingStrategy);
this.searchStrategy = searchingStrategy;
queryParser = new QueryParser(
Version.LUCENE_44,
FbIndexField.TEXT.fieldName(),
searchingStrategy.equals("exact") ? new KeywordAnalyzer() : new StandardAnalyzer(Version.LUCENE_44));
LogInfo.log("Opening index dir: " + indexDir);
IndexReader indexReader = DirectoryReader.open(SimpleFSDirectory.open(new File(indexDir)));
indexSearcher = new IndexSearcher(indexReader);
LogInfo.log("Opened index with " + indexReader.numDocs() + " documents.");
this.numOfDocs = numOfDocs;
LogInfo.end_track();
}
示例2: Search
/**
* 查詢方法
* @throws IOException
* @throws CorruptIndexException
* @throws ParseException
*/
public List Search(String searchString,LuceneResultCollector luceneResultCollector) throws CorruptIndexException, IOException, ParseException{
//方法一:
System.out.println(this.indexSettings.getAnalyzer().getClass()+"----分詞選擇");
QueryParser q = new QueryParser(Version.LUCENE_44, "summary", this.indexSettings.getAnalyzer());
String search = new String(searchString.getBytes("ISO-8859-1"),"UTF-8");
System.out.println(search+"----------搜索的詞語dd");
Query query = q.parse(search);
//方法二:
/*
Term t = new Term("title", searchString);
TermQuery query = new TermQuery(t);
*/
System.out.println(query.toString()+"--------query.tostring");
ScoreDoc[] docs = this.indexSearcher.search(query,100).scoreDocs;
System.out.println("一共有:"+docs.length+"條記錄");
List result = luceneResultCollector.collect(docs, this.indexSearcher);
return result;
}
示例3: FbEntityIndexer
public FbEntityIndexer(String namefile, String outputDir, String indexingStrategy) throws IOException {
if (!indexingStrategy.equals("exact") && !indexingStrategy.equals("inexact"))
throw new RuntimeException("Bad indexing strategy: " + indexingStrategy);
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_44 , indexingStrategy.equals("exact") ? new KeywordAnalyzer() : new StandardAnalyzer(Version.LUCENE_44));
config.setOpenMode(OpenMode.CREATE);
config.setRAMBufferSizeMB(256.0);
indexer = new IndexWriter(new SimpleFSDirectory(new File(outputDir)), config);
this.nameFile = namefile;
}
示例4: createRAMDirectory
/**
* 創建內存目錄
*/
public void createRAMDirectory() throws Exception {
this.directory = new RAMDirectory();
IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_44, this.analyzer);
IndexWriter indexWriter = new IndexWriter(this.directory, indexWriterConfig);
indexWriter.close();
}
示例5: createFSDirectory
/**
* 創建磁盤目錄
*/
public void createFSDirectory(String path) throws Exception {
this.directory = FSDirectory.open(new File(path));
IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_44, this.analyzer);
IndexWriter indexWriter = new IndexWriter(this.directory, indexWriterConfig);
indexWriter.close();
}
示例6: lemmatize
public static String lemmatize(String query) {
StringBuilder sb = new StringBuilder();
ItalianAnalyzer analyzer = new ItalianAnalyzer(Version.LUCENE_44);
TokenStream tokenStream;
try {
tokenStream = analyzer.tokenStream("label", query);
CharTermAttribute token = tokenStream.getAttribute(CharTermAttribute.class);
tokenStream.reset();
while (tokenStream.incrementToken()) {
if (sb.length() > 0) {
sb.append(" ");
}
sb.append(token.toString());
}
analyzer.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
sb = new StringBuilder();
sb.append(query);
}
return sb.toString();
}