Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BoboIndexReader


      writer.addDocument(d);
      writer.optimize();
      writer.commit();
    }
    IndexReader idxReader = IndexReader.open(idxDir,true);
    BoboIndexReader boboReader = BoboIndexReader.getInstance(idxReader,facetHandlers);
    BoboBrowser browser = new BoboBrowser(boboReader);
    List<String> ranges = new ArrayList<String>();
    ranges.add("000000001");
    ranges.add("000010000");// one hour
    ranges.add("000020000");// two hours
View Full Code Here


    s5.add("E");
    NoopFacetHandler h5 = new NoopFacetHandler("E",s5);
    list.add(h5);
   
   
    BoboIndexReader boboReader = BoboIndexReader.getInstance(reader,list, null);
   
    BoboBrowser browser = new BoboBrowser(boboReader);
    HashSet<String> s6 = new HashSet<String>();
    s6.add("A");
    s6.add("B");
    s6.add("C");
    s6.add("D");
    browser.setFacetHandler(new NoopFacetHandler("runtime",s6));
   
    Set<String> expected = new  HashSet<String>();
    expected.add("A");
    expected.add("B");
    expected.add("C");
    expected.add("D");
    expected.add("E");
    expected.add("runtime");
   
    Set<String> facetsLoaded = browser.getFacetNames();
   
    Iterator<String> iter = facetsLoaded.iterator();
    while(iter.hasNext())
    {
      String name = iter.next();
      if (expected.contains(name))
      {
        expected.remove(name);
      }
      else
      {
        fail(name+" is not in expected set.");
      }
    }
   
    if (expected.size() > 0)
    {
      fail("some facets not loaded: "+expected);
    }
   
    boboReader.close();
    browser.close();
  }
View Full Code Here

    s5.add("E");
    NoopFacetHandler h5 = new NoopFacetHandler("E",s5);
    list.add(h5);
   
   
    BoboIndexReader boboReader = BoboIndexReader.getInstance(reader,list, null);
   
    BoboBrowser browser = new BoboBrowser(boboReader);
   
   
    Set<String> expected = new  HashSet<String>();
    expected.add("A");
    expected.add("B");
    expected.add("C");
    expected.add("D");
    expected.add("E");
   
    Set<String> facetsLoaded = browser.getFacetNames();
   
    Iterator<String> iter = facetsLoaded.iterator();
    while(iter.hasNext())
    {
      String name = iter.next();
      if (expected.contains(name))
      {
        expected.remove(name);
      }
      else
      {
        fail(name+" is not in expected set.");
      }
    }
   
    if (expected.size() > 0)
    {
      if (expected.size() == 4)
      {
        expected.remove("A");
        expected.remove("B");
        expected.remove("C");
        expected.remove("D");
        if (expected.size() > 0)
        {
          fail("some facets not loaded: "+expected);
        }
      }
      else
      {
        fail("incorrect number of left over facets: "+expected);
      }
    }
    else
    {
      fail("some facets should not have been loaded.");
    }
   
    boboReader.close();
    browser.close();
  }
View Full Code Here

    File outDir=new File(args[1]);
   
    FileWriter writer=null;
    IndexDumper dumper=new IndexDumper(idxDir);

    BoboIndexReader idxReader=dumper._reader;
    try{
      outDir.mkdirs();
      File outFile=new File(outDir,"dataout.txt");
      if (!outFile.exists()) outFile.createNewFile();
     
      writer=new FileWriter(outFile);
      BufferedWriter bwriter=new BufferedWriter(writer);
      dumper=new IndexDumper(idxDir);
      Set<String> fields=idxReader.getFacetNames();
     
      for (int k=0;k<idxReader.maxDoc();++k){
        for (String field : fields){
          FacetHandler facetHandler = idxReader.getFacetHandler(field);
          if (facetHandler!=null){
            String[] f=facetHandler.getFieldValues(idxReader,k);
            StringBuilder buffer=new StringBuilder();
            buffer.append(field).append(':');
            for (int l=0;l<f.length;++l){
View Full Code Here

    File outfile = new File(_outDir,"facetvals.txt");
    BufferedOutputStream ostream = new BufferedOutputStream(new FileOutputStream(outfile));
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(ostream,"UTF-8"));
   
    IndexReader reader=IndexReader.open(_idxDir);
    BoboIndexReader boboReader = BoboIndexReader.getInstance(reader);
   
    Set<String> fieldNames = boboReader.getFacetNames();
    for (String fieldName : fieldNames)
    {
      TermEnum te = reader.terms(new Term(fieldName,""));
      while(te.next())
      {
        Term t = te.term();
        if (!fieldName.equals(t.field())) break;
        writer.println(t.field()+":"+t.text());
      }
      te.close();
    }
    writer.flush();
    writer.close();
   
    boboReader.close();
  }
View Full Code Here

   
    @Override
    public DocComparator getComparator(IndexReader reader, int docbase)
        throws IOException {
      if (!(reader instanceof BoboIndexReader)) throw new IllegalStateException("reader not instance of "+BoboIndexReader.class);
      BoboIndexReader boboReader = (BoboIndexReader)reader;
      final FacetDataCache dataCache = _facetHandler.getFacetData(boboReader);
      final BigSegmentedArray orderArray = dataCache.orderArray;
      return new DocComparator() {
       
        @Override
View Full Code Here

    BrowseHit[] hits = new BrowseHit[scoreDocs.length];
    Collection<FacetHandler<?>> facetHandlers= facetHandlerMap.values();
    for (int i =scoreDocs.length-1; i >=0 ; i--)
    {
      MyScoreDoc fdoc = scoreDocs[i];
      BoboIndexReader reader = fdoc.reader;
      BrowseHit hit=new BrowseHit();
      if (fetchStoredFields){

        hit.setStoredFields(reader.document(fdoc.doc));
      }
      Map<String,String[]> map = new HashMap<String,String[]>();
      Map<String,Object[]> rawMap = new HashMap<String,Object[]>();
      for (FacetHandler<?> facetHandler : facetHandlers)
      {
View Full Code Here

   
    @Override
    public DocComparator getComparator(final IndexReader reader, int docbase)
        throws IOException {
      if (!(reader instanceof BoboIndexReader)) throw new IllegalStateException("reader must be instance of "+BoboIndexReader.class);
      BoboIndexReader boboReader = (BoboIndexReader)reader;
      final MultiValueFacetDataCache dataCache = _facetHandler.getFacetData(boboReader);
      return new DocComparator(){
       
        @Override
        public int compare(ScoreDoc doc1, ScoreDoc doc2) {
View Full Code Here

  }
 
  public Explanation explain(IndexReader indexReader, int docid, Explanation innerExplaination) throws IOException
  {
    if(!(indexReader instanceof BoboIndexReader)) throw new IllegalArgumentException("IndexReader is not BoboIndexReader");
    BoboIndexReader reader = (BoboIndexReader)indexReader;
   
    Explanation exp = new Explanation();
    exp.setDescription("FacetBasedBoost");
   
    float boost = 1.0f;
    for(Map.Entry<String,Map<String,Float>> boostEntry : _boostMaps.entrySet())
    {
      String facetName = boostEntry.getKey();
      FacetHandler<?> handler = reader.getFacetHandler(facetName);
      if(!(handler instanceof FacetScoreable))
        throw new IllegalArgumentException(facetName + " does not implement FacetScoreable");
       
      FacetScoreable facetScoreable = (FacetScoreable)handler;
      BoboDocScorer scorer = facetScoreable.getDocScorer(reader, _scoringFunctionFactory, boostEntry.getValue());
View Full Code Here

          _similarity = sim;
    }
       
    public Explanation explain(IndexReader reader, int docid)
        throws IOException {
      BoboIndexReader boboReader = (BoboIndexReader)reader;
      FacetHandler<?> fhandler = boboReader.getFacetHandler(FacetTermQuery.this._name);
      if (fhandler!=null){
         BoboDocScorer scorer = null;
         if (fhandler instanceof FacetScoreable){
           scorer = ((FacetScoreable)fhandler).getDocScorer(boboReader,_scoringFactory, _boostMap);
           Explanation exp1 =  scorer.explain(docid);
View Full Code Here

TOP

Related Classes of com.browseengine.bobo.api.BoboIndexReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.