Esempio n. 1
0
 @Override
 public void createWeight(QueryContext context, IndexSearcher searcher) throws IOException {
   TFIDFSimilarity sim = asTFIDF(searcher.getSimilarity(), field);
   if (sim == null) {
     throw new UnsupportedOperationException(
         "requires a TFIDFSimilarity (such as DefaultSimilarity)");
   }
   int docfreq = searcher.getIndexReader().docFreq(new Term(indexedField, indexedBytes));
   float idf = sim.idf(docfreq, searcher.getIndexReader().maxDoc());
   FuncValues result = new ConstDoubleDocValues(idf, this);
   context.put(this, result);
 }
Esempio n. 2
0
  /**
   * factory method for invoking json facet framework as whole. Note: this is currently only used
   * from SimpleFacets, not from JSON Facet API itself.
   */
  public static FacetProcessor<?> createProcessor(
      SolrQueryRequest req, Map<String, Object> params, DocSet docs) {
    FacetParser parser = new FacetTopParser(req);
    FacetRequest facetRequest = null;
    try {
      facetRequest = parser.parse(params);
    } catch (SyntaxError syntaxError) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, syntaxError);
    }

    FacetContext fcontext = new FacetContext();
    fcontext.base = docs;
    fcontext.req = req;
    fcontext.searcher = req.getSearcher();
    fcontext.qcontext = QueryContext.newContext(fcontext.searcher);

    return facetRequest.createFacetProcessor(fcontext);
  }
Esempio n. 3
0
 @Override
 public FuncValues getValues(QueryContext context, AtomicReaderContext readerContext)
     throws IOException {
   return (FuncValues) context.get(this);
 }