本文整理汇总了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();
}