本文整理汇总了Java中org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask类的典型用法代码示例。如果您正苦于以下问题:Java CreateIndexTask类的具体用法?Java CreateIndexTask怎么用?Java CreateIndexTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreateIndexTask类属于org.apache.lucene.benchmark.byTask.tasks包,在下文中一共展示了CreateIndexTask类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Properties p = initProps();
Config conf = new Config(p);
PerfRunData runData = new PerfRunData(conf);
// 1. top sequence
TaskSequence top = new TaskSequence(runData,null,null,false); // top level, not parallel
// 2. task to create the index
CreateIndexTask create = new CreateIndexTask(runData);
top.addTask(create);
// 3. task seq to add 500 docs (order matters - top to bottom - add seq to top, only then add to seq)
TaskSequence seq1 = new TaskSequence(runData,"AddDocs",top,false);
seq1.setRepetitions(500);
seq1.setNoChildReport();
top.addTask(seq1);
// 4. task to add the doc
AddDocTask addDoc = new AddDocTask(runData);
//addDoc.setParams("1200"); // doc size limit if supported
seq1.addTask(addDoc); // order matters 9see comment above)
// 5. task to close the index
CloseIndexTask close = new CloseIndexTask(runData);
top.addTask(close);
// task to report
RepSumByNameTask rep = new RepSumByNameTask(runData);
top.addTask(rep);
// print algorithm
System.out.println(top.toString());
// execute
top.doLogic();
}
开发者ID:europeana,项目名称:search,代码行数:38,代码来源:Sample.java
示例2: doTestIndexProperties
import org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask; //导入依赖的package包/类
private void doTestIndexProperties(boolean setIndexProps,
boolean indexPropsVal, int numExpectedResults) throws Exception {
Properties props = new Properties();
// Indexing configuration.
props.setProperty("analyzer", WhitespaceAnalyzer.class.getName());
props.setProperty("content.source", OneDocSource.class.getName());
props.setProperty("directory", "RAMDirectory");
if (setIndexProps) {
props.setProperty("doc.index.props", Boolean.toString(indexPropsVal));
}
// Create PerfRunData
Config config = new Config(props);
PerfRunData runData = new PerfRunData(config);
TaskSequence tasks = new TaskSequence(runData, getTestName(), null, false);
tasks.addTask(new CreateIndexTask(runData));
tasks.addTask(new AddDocTask(runData));
tasks.addTask(new CloseIndexTask(runData));
tasks.doLogic();
IndexReader reader = DirectoryReader.open(runData.getDirectory());
IndexSearcher searcher = newSearcher(reader);
TopDocs td = searcher.search(new TermQuery(new Term("key", "value")), 10);
assertEquals(numExpectedResults, td.totalHits);
reader.close();
}
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:DocMakerTest.java
示例3: doTestIndexProperties
import org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask; //导入依赖的package包/类
private void doTestIndexProperties(boolean setIndexProps,
boolean indexPropsVal, int numExpectedResults) throws Exception {
Properties props = new Properties();
// Indexing configuration.
props.setProperty("analyzer", WhitespaceAnalyzer.class.getName());
props.setProperty("content.source", OneDocSource.class.getName());
props.setProperty("directory", "RAMDirectory");
if (setIndexProps) {
props.setProperty("doc.index.props", Boolean.toString(indexPropsVal));
}
// Create PerfRunData
Config config = new Config(props);
PerfRunData runData = new PerfRunData(config);
TaskSequence tasks = new TaskSequence(runData, getTestName(), null, false);
tasks.addTask(new CreateIndexTask(runData));
tasks.addTask(new AddDocTask(runData));
tasks.addTask(new CloseIndexTask(runData));
tasks.doLogic();
IndexReader reader = DirectoryReader.open(runData.getDirectory());
IndexSearcher searcher = new IndexSearcher(reader);
TopDocs td = searcher.search(new TermQuery(new Term("key", "value")), 10);
assertEquals(numExpectedResults, td.totalHits);
reader.close();
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:29,代码来源:DocMakerTest.java
示例4: doIndexAndSearchTestWithRepeats
import org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask; //导入依赖的package包/类
private void doIndexAndSearchTestWithRepeats(File file,
Class<? extends LineParser> lineParserClass, int numAdds, String storedField) throws Exception {
IndexReader reader = null;
IndexSearcher searcher = null;
PerfRunData runData = null;
try {
Properties props = new Properties();
// LineDocSource specific settings.
props.setProperty("docs.file", file.getAbsolutePath());
if (lineParserClass != null) {
props.setProperty("line.parser", lineParserClass.getName());
}
// Indexing configuration.
props.setProperty("analyzer", WhitespaceAnalyzer.class.getName());
props.setProperty("content.source", LineDocSource.class.getName());
props.setProperty("directory", "RAMDirectory");
props.setProperty("doc.stored", "true");
props.setProperty("doc.index.props", "true");
// Create PerfRunData
Config config = new Config(props);
runData = new PerfRunData(config);
TaskSequence tasks = new TaskSequence(runData, "testBzip2", null, false);
tasks.addTask(new CreateIndexTask(runData));
for (int i=0; i<numAdds; i++) {
tasks.addTask(new AddDocTask(runData));
}
tasks.addTask(new CloseIndexTask(runData));
try {
tasks.doLogic();
} finally {
tasks.close();
}
reader = DirectoryReader.open(runData.getDirectory());
searcher = new IndexSearcher(reader);
TopDocs td = searcher.search(new TermQuery(new Term("body", "body")), 10);
assertEquals(numAdds, td.totalHits);
assertNotNull(td.scoreDocs[0]);
if (storedField==null) {
storedField = DocMaker.BODY_FIELD; // added to all docs and satisfies field-name == value
}
assertEquals("Wrong field value", storedField, searcher.doc(0).get(storedField));
} finally {
IOUtils.close(reader, runData);
}
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:54,代码来源:LineDocSourceTest.java
示例5: doIndexAndSearchTestWithRepeats
import org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask; //导入依赖的package包/类
private void doIndexAndSearchTestWithRepeats(File file,
Class<? extends LineParser> lineParserClass, int numAdds, String storedField) throws Exception {
IndexReader reader = null;
IndexSearcher searcher = null;
PerfRunData runData = null;
try {
Properties props = new Properties();
// LineDocSource specific settings.
props.setProperty("docs.file", file.getAbsolutePath());
if (lineParserClass != null) {
props.setProperty("line.parser", lineParserClass.getName());
}
// Indexing configuration.
props.setProperty("analyzer", WhitespaceAnalyzer.class.getName());
props.setProperty("content.source", LineDocSource.class.getName());
props.setProperty("directory", "RAMDirectory");
props.setProperty("doc.stored", "true");
props.setProperty("doc.index.props", "true");
// Create PerfRunData
Config config = new Config(props);
runData = new PerfRunData(config);
TaskSequence tasks = new TaskSequence(runData, "testBzip2", null, false);
tasks.addTask(new CreateIndexTask(runData));
for (int i=0; i<numAdds; i++) {
tasks.addTask(new AddDocTask(runData));
}
tasks.addTask(new CloseIndexTask(runData));
try {
tasks.doLogic();
} finally {
tasks.close();
}
reader = DirectoryReader.open(runData.getDirectory());
searcher = newSearcher(reader);
TopDocs td = searcher.search(new TermQuery(new Term("body", "body")), 10);
assertEquals(numAdds, td.totalHits);
assertNotNull(td.scoreDocs[0]);
if (storedField==null) {
storedField = DocMaker.BODY_FIELD; // added to all docs and satisfies field-name == value
}
assertEquals("Wrong field value", storedField, searcher.doc(0).get(storedField));
} finally {
IOUtils.close(reader, runData);
}
}
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:54,代码来源:LineDocSourceTest.java
注:本文中的org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论