Package org.apache.solr.util

Examples of org.apache.solr.util.NamedList


      if (qs.startsWith("values")) {
        rsp.add("testname1","testval1");

        rsp.add("testarr1",new String[]{"my val 1","my val 2"});

        NamedList nl = new NamedList();
        nl.add("myInt", 333);
        nl.add("myNullVal", null);
        nl.add("myFloat",1.414213562f);
        nl.add("myDouble", 1e100d);
        nl.add("myBool", false);
        nl.add("myLong",999999999999L);

        Document doc = new Document();
        doc.add(new Field("id","55",Field.Store.YES, Field.Index.UN_TOKENIZED));
        nl.add("myDoc",doc);

        nl.add("myResult",results);
        nl.add("myStr","&wow! test escaping: a&b<c&");
        nl.add(null, "this value had a null name...");
        nl.add("myIntArray", new Integer[] { 100, 5, -10, 42 });
        nl.add("epoch", new Date(0));
        nl.add("currDate", new Date(System.currentTimeMillis()));
        rsp.add("myNamedList", nl);
      } else if (qs.startsWith("fields")) {
        NamedList nl = new NamedList();
        Collection flst;
        flst = searcher.getReader().getFieldNames(IndexReader.FieldOption.INDEXED);
        nl.add("indexed",flst);
        flst = searcher.getReader().getFieldNames(IndexReader.FieldOption.UNINDEXED);
        nl.add("unindexed",flst);
        rsp.add("fields", nl);
      }

      test(results.size() <= limit);
      test(results.size() <= results.matches());
View Full Code Here


  public URL[] getDocs() {
    return null;
  }

  public NamedList getStatistics() {
    NamedList lst = new NamedList();
    lst.add("requests", numRequests);
    lst.add("errors", numErrors);
    return lst;
  }
View Full Code Here

          // count = sortSpec.getCount();
        }
      }

      DocListAndSet results = new DocListAndSet();
      NamedList facetInfo = null;
      List<Query> filters = U.parseFilterQueries(req);
      SolrIndexSearcher s = req.getSearcher();

      if (p.getBool(FACET,false)) {
        results = s.getDocListAndSet(query, filters, sort,
                                     p.getInt(START,0), p.getInt(ROWS,10),
                                     flags);
        facetInfo = getFacetInfo(req, rsp, results.docSet);
      } else {
        results.docList = s.getDocList(query, filters, sort,
                                       p.getInt(START,0), p.getInt(ROWS,10),
                                       flags);
      }

      // pre-fetch returned documents
      U.optimizePreFetchDocs(results.docList, query, req, rsp);
     
      rsp.add("response",results.docList);

      if (null != facetInfo) rsp.add("facet_counts", facetInfo);

      try {
        NamedList dbg = U.doStandardDebug(req, qs, query, results.docList);
        if (null != dbg) {
          if (null != filters) {
            dbg.add("filter_queries",req.getParams().getParams(FQ));
            List<String> fqs = new ArrayList<String>(filters.size());
            for (Query fq : filters) {
              fqs.add(QueryParsing.toString(fq, req.getSchema()));
            }
            dbg.add("parsed_filter_queries",fqs);
          }
          rsp.add("debug", dbg);
        }
      } catch (Exception e) {
        SolrException.logOnce(SolrCore.log, "Exception during debug", e);
        rsp.add("exception_during_debug", SolrException.toStr(e));
      }

      NamedList sumData = HighlightingUtils.doHighlighting(
        results.docList, query, req, new String[]{defaultField});
      if(sumData != null)
        rsp.add("highlighting", sumData);

    } catch (SolrException e) {
View Full Code Here

  public URL[] getDocs() {
    return null;
  }

  public NamedList getStatistics() {
    NamedList lst = new NamedList();
    lst.add("requests", numRequests);
    lst.add("errors", numErrors);
    return lst;
  }
View Full Code Here

    return Integer.toString(ones) + '.' + tenths;
    ***/
  }

  public NamedList getStatistics() {
    NamedList lst = new NamedList();
    synchronized (map) {
      lst.add("lookups", lookups);
      lst.add("hits", hits);
      lst.add("hitratio", calcHitRatio(lookups,hits));
      lst.add("inserts", inserts);
      lst.add("evictions", evictions);
      lst.add("size", map.size());
    }

    long clookups = stats.lookups.get();
    long chits = stats.hits.get();
    lst.add("cumulative_lookups", clookups);
    lst.add("cumulative_hits", chits);
    lst.add("cumulative_hitratio", calcHitRatio(clookups,chits));
    lst.add("cumulative_inserts", stats.inserts.get());
    lst.add("cumulative_evictions", stats.evictions.get());

    return lst;
  }
View Full Code Here

    // if someone called this method, benefit of the doubt: assume true
    if (!params.getBool(params.FACET,true))
      return null;

    NamedList res = new NamedList();
    try {

      res.add("facet_queries", getFacetQueryCounts());

      res.add("facet_fields", getFacetFieldCounts());

    } catch (Exception e) {
      SolrException.logOnce(SolrCore.log, "Exception during facet counts", e);
      res.add("exception", SolrException.toStr(e));
    }
    return res;
  }
View Full Code Here

  public URL[] getDocs() {
    return null;
  }

  public NamedList getStatistics() {
    NamedList lst = new NamedList();
    lst.add("requests", numRequests);
    lst.add("errors", numErrors);
    return lst;
  }
View Full Code Here

   *
   * @see SolrParams#FACET_QUERY
   */
  public NamedList getFacetQueryCounts() throws IOException,ParseException {

    NamedList res = new NamedList();

    /* Ignore SolrParams.DF - could have init param facet.query assuming
     * the schema default with query param DF intented to only affect Q.
     * If user doesn't want schema default for facet.query, they should be
     * explicit.
     */
    SolrQueryParser qp = new SolrQueryParser(searcher.getSchema(),null);

    String[] facetQs = params.getParams(SolrParams.FACET_QUERY);
    if (null != facetQs && 0 != facetQs.length) {
      for (String q : facetQs) {
        res.add(q, searcher.numDocs(qp.parse(q), docs));
      }
    }

    return res;
  }
View Full Code Here

  public NamedList getTermCounts(String field) throws IOException {
    int limit = params.getFieldInt(field, params.FACET_LIMIT, 100);
    boolean zeros = params.getFieldBool(field, params.FACET_ZEROS, true);
    boolean missing = params.getFieldBool(field, params.FACET_MISSING, false);

    NamedList counts;
    SchemaField sf = searcher.getSchema().getField(field);
    FieldType ft = sf.getType();
    if (sf.multiValued() || ft.isTokenized() || ft instanceof BoolField) {
      // Always use filters for booleans... we know the number of values is very small.
      counts = getFacetTermEnumCounts(searcher,docs,field,limit,zeros,missing);
View Full Code Here

   * @see #getFacetTermEnumCounts
   */
  public NamedList getFacetFieldCounts()
          throws IOException {

    NamedList res = new NamedList();
    String[] facetFs = params.getParams(SolrParams.FACET_FIELD);
    if (null != facetFs) {
      for (String f : facetFs) {
        res.add(f, getTermCounts(f));
      }
    }
    return res;
  }
View Full Code Here

TOP

Related Classes of org.apache.solr.util.NamedList

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.