Java 类org.apache.lucene.search.CachingWrapperFilter 实例源码

项目:search    文件:ChainedFilterTest.java   
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();
}
项目:NYBC    文件:ChainedFilterTest.java   
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();
}
项目:Maskana-Gestor-de-Conocimiento    文件:ChainedFilterTest.java   
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();
}
项目:bisis-v4    文件:GroupInvRecordUtils.java   
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]);      
}
项目:bisis-v4    文件:GroupInvRecordUtils.java   
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;      
}
项目:bisis-v4    文件:FilterManager.java   
public FilterManager(List filterInvs){
  filter = new CachingWrapperFilter(new BisisFilter(filterInvs));
}
项目:bisis-v4    文件:ReportRunner.java   
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;
}
项目:t4f-data    文件:ChainedFilterTest.java   
@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"))));
}