本文整理汇总了Java中org.apache.lucene.search.CachingWrapperFilter类的典型用法代码示例。如果您正苦于以下问题:Java CachingWrapperFilter类的具体用法?Java CachingWrapperFilter怎么用?Java CachingWrapperFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CachingWrapperFilter类属于org.apache.lucene.search包,在下文中一共展示了CachingWrapperFilter类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWithCachingFilter
import org.apache.lucene.search.CachingWrapperFilter; //导入依赖的package包/类
public void testWithCachingFilter() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
IndexReader reader = writer.getReader();
writer.close();
IndexSearcher searcher = newSearcher(reader);
Query query = new TermQuery(new Term("none", "none"));
QueryWrapperFilter queryFilter = new QueryWrapperFilter(query);
CachingWrapperFilter cachingFilter = new CachingWrapperFilter(queryFilter);
searcher.search(query, cachingFilter, 1);
CachingWrapperFilter cachingFilter2 = new CachingWrapperFilter(queryFilter);
Filter[] chain = new Filter[2];
chain[0] = cachingFilter;
chain[1] = cachingFilter2;
ChainedFilter cf = new ChainedFilter(chain);
// throws java.lang.ClassCastException: org.apache.lucene.util.OpenBitSet cannot be cast to java.util.BitSet
searcher.search(new MatchAllDocsQuery(), cf, 1);
reader.close();
dir.close();
}
示例2: getRecordForInv
import org.apache.lucene.search.CachingWrapperFilter; //导入依赖的package包/类
public static Record getRecordForInv(String invBroj){
List<String> invList = new ArrayList<String>();
invList.add(invBroj);
CachingWrapperFilter filter = new CachingWrapperFilter(new BisisFilter(invList));
int[] recordIds = BisisApp.getRecordManager().select3(new MatchAllDocsQuery(),filter, null);
if(recordIds.length==0) return null;
return BisisApp.getRecordManager().getRecord(recordIds[0]);
}
示例3: getRecordsForInvs
import org.apache.lucene.search.CachingWrapperFilter; //导入依赖的package包/类
public static List<Record> getRecordsForInvs(List<String> invList){
CachingWrapperFilter filter = new CachingWrapperFilter(new BisisFilter(invList));
int[] recordIds = BisisApp.getRecordManager().select3(new MatchAllDocsQuery(),filter, null);
List<Record> recList = new ArrayList<Record>();
for(Record rec: BisisApp.getRecordManager().getRecords(recordIds))
recList.add(rec);
return recList;
}
示例4: FilterManager
import org.apache.lucene.search.CachingWrapperFilter; //导入依赖的package包/类
public FilterManager(List filterInvs){
filter = new CachingWrapperFilter(new BisisFilter(filterInvs));
}
示例5: run
import org.apache.lucene.search.CachingWrapperFilter; //导入依赖的package包/类
public JasperPrint run(String odInvBr, String doInvBr, String reportName) {
JasperPrint jp = null;
try {
List<String> listaInventarnih = new ArrayList<String>();
int odBr = Integer.parseInt(odInvBr.substring(4));
String odeljenje = odInvBr.substring(0, 2);
String tippubl = odInvBr.substring(2, 4);
int doBr = Integer.parseInt(doInvBr.substring(4));
for (int brojac = odBr; brojac <= doBr; brojac++) {
String brojStr = String.valueOf(brojac);
brojStr = "00000000000".substring(0, 7 - brojStr.length())
+ brojStr;
listaInventarnih.add(odeljenje + tippubl + brojStr);
}
CachingWrapperFilter filter = new CachingWrapperFilter(
new BisisFilter(listaInventarnih));
Result result = BisisApp.getRecordManager().selectAll3x(
SerializationUtils.serialize(new MatchAllDocsQuery()),
SerializationUtils.serialize(filter), null);
Record[] records = BisisApp.getRecordManager().getRecords(result.getRecords());
StringBuffer buff = new StringBuffer();
for (Report r : reportCollection.getReports()) {
if (!r.getReportSettings().getParam("menuitem").equalsIgnoreCase(reportName))
continue;
buff.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
buff.append("<report>");
r.init();
for (Record rec : records) {
r.handleRecord(rec);
}
r.finishOnline(buff);
buff.append("</report>");
JRXmlDataSource dataSource = new JRXmlDataSource(XMLUtils
.getDocumentFromString(buff.toString()),
"/report/item");
Map param = new HashMap();
if (r.getReportSettings().getParam("subjasper") != null) {
JasperReport subreport = (JasperReport) JRLoader
.loadObject(ReportRunner.class.getResource(
r.getReportSettings().getParam(
"subjasper")).openStream());
param.put("subjasper", subreport);
}
jp = JasperFillManager.fillReport(ReportRunner.class
.getResource(
r.getReportSettings().getParam("jasper"))
.openStream(), param, dataSource);
}
} catch (Exception e) {
e.printStackTrace();
}
return jp;
}
示例6: setUp
import org.apache.lucene.search.CachingWrapperFilter; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
directory = new RAMDirectory();
IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(Version.LUCENE_41),
IndexWriter.MaxFieldLength.UNLIMITED);
Calendar cal = Calendar.getInstance();
cal.set(2009, 1, 1, 0, 0);
for (int i = 0; i < MAX; i++) {
Document doc = new Document();
doc.add(new Field("key", "" + (i + 1), Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("owner", (i < MAX / 2) ? "bob" : "sue", Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("date", DateTools.timeToString(cal.getTimeInMillis(), DateTools.Resolution.DAY),
Field.Store.YES, Field.Index.NOT_ANALYZED));
writer.addDocument(doc);
cal.add(Calendar.DATE, 1);
}
writer.close();
searcher = new IndexSearcher(directory);
BooleanQuery bq = new BooleanQuery();
bq.add(new TermQuery(new Term("owner", "bob")),
BooleanClause.Occur.SHOULD);
bq.add(new TermQuery(new Term("owner", "sue")),
BooleanClause.Occur.SHOULD);
query = bq;
cal.set(2099, 1, 1, 0, 0);
dateFilter = TermRangeFilter.Less("date",
DateTools.timeToString(
cal.getTimeInMillis(),
DateTools.Resolution.DAY));// C
bobFilter = new CachingWrapperFilter(
new QueryWrapperFilter(
new TermQuery(new Term("owner", "bob"))));
sueFilter = new CachingWrapperFilter(
new QueryWrapperFilter(
new TermQuery(new Term("owner", "sue"))));
}