Package org.apache.solr.util

Examples of org.apache.solr.util.NamedList


      // parse the query from the 'q' parameter (sort has been striped)
      Query query = QueryParsing.parseQuery(qstr, defaultField, p, req.getSchema());
     
      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, qstr, 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.rewrite(req.getSearcher().getReader()), req, new String[]{defaultField});
      if(sumData != null)
        rsp.add("highlighting", sumData);
  }
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

      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

    // TODO: check for nested tags and parse as a named list instead
    String urlSnippet = config.get("admin/pingQuery", "").trim();
   
    StringTokenizer qtokens = new StringTokenizer(urlSnippet,"&");
    String tok;
    NamedList params = new NamedList();
    while (qtokens.hasMoreTokens()) {
      tok = qtokens.nextToken();
      String[] split = tok.split("=", 2);
      params.add(split[0], split[1]);
    }
    return new LocalSolrQueryRequest(core, params);
  }
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

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

  public NamedList getStatistics() {
    NamedList lst = new SimpleOrderedMap();
    return lst;
  }
View Full Code Here

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

  public NamedList getStatistics() {
    NamedList lst = new SimpleOrderedMap();
    lst.add("caching", cachingEnabled);
    lst.add("numDocs", reader.numDocs());
    lst.add("maxDoc", reader.maxDoc());
    lst.add("readerImpl", reader.getClass().getSimpleName());
    lst.add("readerDir", reader.directory());
    lst.add("indexVersion", reader.getVersion());
    lst.add("openedAt", new Date(openTime));
    if (registerTime!=0) lst.add("registeredAt", new Date(registerTime));
    return lst;
  }
View Full Code Here

  public URL[] getDocs() {
    return null// this can be overridden, but not required
  }

  public NamedList getStatistics() {
    NamedList lst = new SimpleOrderedMap();
    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 SimpleOrderedMap();
    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

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

  public NamedList getStatistics() {
    NamedList lst = new SimpleOrderedMap();
    lst.add("commits", commitCommands.get());
    if (tracker.docsUpperBound > 0) {
      lst.add("autocommit maxDocs", tracker.docsUpperBound);
    }
    if (tracker.timeUpperBound > 0) {
      lst.add("autocommit maxTime", "" + tracker.timeUpperBound + "ms");
    }
    lst.add("autocommits", tracker.autoCommitCount);
    lst.add("optimizes", optimizeCommands.get());
    lst.add("docsPending", numDocsPending.get());
    // pset.size() not synchronized, but it should be fine to access.
    lst.add("deletesPending", pset.size());
    lst.add("adds", addCommands.get());
    lst.add("deletesById", deleteByIdCommands.get());
    lst.add("deletesByQuery", deleteByQueryCommands.get());
    lst.add("errors", numErrors.get());
    lst.add("cumulative_adds", addCommandsCumulative.get());
    lst.add("cumulative_deletesById", deleteByIdCommandsCumulative.get());
    lst.add("cumulative_deletesByQuery", deleteByQueryCommandsCumulative.get());
    lst.add("cumulative_errors", numErrorsCumulative.get());
    lst.add("docsDeleted", numDocsDeleted.get());
    return lst;
  }
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.