Package org.apache.solr.common.util

Examples of org.apache.solr.common.util.NamedList


    String[] crossFs=query.getParams(FacetParams.FACET_CROSS_FL);
    String[] distFS=query.getParams(FacetParams.FACET_CROSSDIST_FL);
   
    LinkedHashMap<String,GroupbyRow> groupValueCache=new LinkedHashMap<String,GroupbyRow>();

    NamedList ff = (NamedList) qr.get_mdrillData();
   
    long totalRecord = (new RecordCount((ArrayList<Object>) ff.get("count"))).getValue();
       
    if(groupValueCacheLast==null)
    {
      jsonObj.put("code", "1");
      jsonObj.put("message", "success");
      jsonObj.put("total", totalRecord);
    }
     
      JSONObject jsonObj2 = new JSONObject();
      JSONArray jsonArray = new JSONArray();

      ArrayList<Object> facetCounts=(ArrayList<Object>) ff.get("list");

      int fcsize = 0;
      if(facetCounts != null){
        fcsize = facetCounts.size();
      }
View Full Code Here


  public static void setDetailResult(JSONObject jsonObj,QueryResponse qr,
      ArrayList<String> showFields,
      HigoJoinParams[] joins   
  ) throws JSONException
    {
    NamedList ff = (NamedList) qr.get_mdrillData();
    ArrayList<Object> count=(ArrayList<Object>) ff.get("count");
    RecordCountDetail p = new RecordCountDetail(count);
        long totalRecord = p.getValue();
         
        jsonObj.put("code", "1");
        jsonObj.put("message", "success");
       
        JSONObject jsonObj2 = new JSONObject();
        JSONArray jsonArray = new JSONArray();

        ArrayList<Object> facetCounts=(ArrayList<Object>) ff.get("list");
       
        int fcsize = 0;
        if(facetCounts != null){
          fcsize = facetCounts.size();
        }
View Full Code Here

   *
   * @param currentSearcher If null, add FIRST_SEARCHER, otherwise NEW_SEARCHER
   * @param nlst The named list to add the EVENT value to
   */
  protected NamedList addEventParms(SolrIndexSearcher currentSearcher, NamedList nlst) {
    NamedList result = new NamedList();
    result.addAll(nlst);
    if (currentSearcher != null) {
      result.add(EventParams.EVENT, EventParams.NEW_SEARCHER);
    } else {
      result.add(EventParams.EVENT, EventParams.FIRST_SEARCHER);
    }
    return result;
  }
View Full Code Here

          }
          //clear out the entries for the next round
          tvm.passage.clear();
        }
      }
      NamedList qaResp = new NamedList();
      rb.rsp.add("qaResponse", qaResp);
      int rows = params.getInt(QA_ROWS, 5);

      SchemaField uniqField = rb.req.getSchema().getUniqueKeyField();
      if (rankedPassages.size() > 0) {
        int size = Math.min(rows, rankedPassages.size());
        Set<String> fields = new HashSet<String>();
        for (int i = size - 1; i >= 0; i--) {
          Passage passage = rankedPassages.pop();
          if (passage != null) {
            NamedList passNL = new NamedList();
            qaResp.add(("answer"), passNL);
            String idName;
            String idValue;
            if (uniqField != null) {
              idName = uniqField.getName();
              fields.add(idName);
              fields.add(passage.field);//prefetch this now, so that it is cached
              idValue = searcher.doc(passage.lDocId, fields).get(idName);
            } else {
              idName = "luceneDocId";
              idValue = String.valueOf(passage.lDocId);
            }
            passNL.add(idName, idValue);
            passNL.add("field", passage.field);
            //get the window
            String fldValue = searcher.doc(passage.lDocId, fields).get(passage.field);
            if (fldValue != null) {
              //get the window of words to display, we don't use the passage window, as that is based on the term vector
              int start = passage.terms.first().start;//use the offsets
              int end = passage.terms.last().end;
              if (start >= 0 && start < fldValue.length() &&
                      end >= 0 && end < fldValue.length()) {
                passNL.add("window", fldValue.substring(start, end + passage.terms.last().term.length()));
              } else {
                log.debug("Passage does not have correct offset information");
                passNL.add("window", fldValue);//we don't have offsets, or they are incorrect, return the whole field value
              }
            }
          } else {
            break;
          }
View Full Code Here

  @Override
  public void write(Writer w, SolrQueryRequest req,
                    SolrQueryResponse rsp) throws IOException {
    SolrIndexSearcher searcher = req.getSearcher();
    NamedList nl = rsp.getValues();
    int sz = nl.size();
    for (int li = 0; li < sz; li++) {
      Object val = nl.getVal(li);
      if (val instanceof DocList) { //<co id="co.fuzzy.type-ahead.doclist"/>
        DocList dl = (DocList) val;
        DocIterator iterator = dl.iterator();
        w.append("<ul>\n");
        while (iterator.hasNext()) {
View Full Code Here

      String charset = EntityUtils.getContentCharSet(response.getEntity());
      NamedList<Object> rsp = processor.processResponse(respBody, charset);
      if (httpStatus != HttpStatus.SC_OK) {
        String reason = null;
        try {
          NamedList err = (NamedList) rsp.get("error");
          if (err != null) {
            reason = (String) err.get("msg");
            // TODO? get the trace?
          }
        } catch (Exception ex) {}
        if (reason == null) {
          StringBuilder msg = new StringBuilder();
View Full Code Here

        mapDataBean.setName(key2);
        Collection<MapPointBean> fullData = new ArrayList<MapPointBean>();

        try
        {
            NamedList result = (NamedList) ((SimpleOrderedMap) ((SimpleOrderedMap) solrResponse
                    .getResponse().get("facet_counts")).get("facet_fields"))
                    .get(key3);
            int limit = result.size();
            if (key3.equals(_CONTINENT) && hitsNumber != null && hitsNumber > 0)
            {
                limit = hitsNumber;
            }
            else if (key3.equals(_COUNTRY_CODE) && hitsNumber != null
                    && hitsNumber > 0)
            {
                limit = hitsNumber;
            }
            if (key3.equals(_CITY) && hitsNumber != null && hitsNumber > 0)
            {
                limit = hitsNumber;
            }

            Integer other = 0;

            for (int i = 0; i < result.size(); i++)
            {
                try
                {
                    if (result.getVal(i).getClass().equals(Integer.class))
                    {
                        StringTokenizer st = new StringTokenizer(
                                (result.getName(i)).toString(),
                                DELIM_LATITUDE_LONGITUDE);
                        MapPointBean mapPointBean = new MapPointBean(
                                st.nextToken(), st.nextToken(),
                                (Integer) result.getVal(i));
                        fullData.add(mapPointBean);
                    }

                }
                catch (Exception e)
                {
                    fullData.add(new MapPointBean(_NotAvailable, _NotAvailable,
                            null));
                    e.printStackTrace();
                }
            }
            mapDataBean.setHits(result.size());
            mapDataBean.setDataTable(fullData);
            try
            {
                mapDataBean.setPercentages();
            }
View Full Code Here

        pieStatisticBean.setName(key2);
        Collection<StatisticDatasBeanRow> fullData = new ArrayList<StatisticDatasBeanRow>();
        Collection<StatisticDatasBeanRow> limitedData = new ArrayList<StatisticDatasBeanRow>();
        try
        {
            NamedList result = (NamedList) ((SimpleOrderedMap) ((SimpleOrderedMap) solrResponse
                    .getResponse().get("facet_counts")).get("facet_fields"))
                    .get(key3);
            int limit = result.size();
            if (key3.equals(_CONTINENT) && hitsNumber != null && hitsNumber > 0)
            {
                limit = hitsNumber;
            }
            else if (key3.equals(_COUNTRY_CODE) && hitsNumber != null
                    && hitsNumber > 0)
            {
                limit = hitsNumber;
            }
            if (key3.equals(_CITY) && hitsNumber != null && hitsNumber > 0)
            {
                limit = hitsNumber;
            }

            Integer other = 0;

            for (int i = 0; i < result.size(); i++)
            {
                try
                {
                    if (result.getVal(i).getClass().equals(Integer.class))
                    {
                        String name = (String) result.getName(i);
                        if (StringUtils.isEmpty(name))
                            name = "Unknown";
                        // if (i<limit && (Integer)result.getVal(i)>0){
                        if (i < limit && !name.equals("Unknown"))
                        {
                            limitedData.add(new StatisticDatasBeanRow(name,
                                    result.getVal(i)));
                        }
                        else
                        {
                            other += (Integer) result.getVal(i);
                        }
                        fullData.add(new StatisticDatasBeanRow(name, result
                                .getVal(i)));
                    }

                }
                catch (Exception e)
                {
                    fullData.add(new StatisticDatasBeanRow(_NotAvailable, null));
                    limitedData.add(new StatisticDatasBeanRow(_NotAvailable,
                            null));
                    e.printStackTrace();
                }
            }
            if (result.size() > limit && other > 0)
            {
                limitedData.add(new StatisticDatasBeanRow(_OTHER, other));
            }
            pieStatisticBean.setHits(result.size());
            pieStatisticBean.setDataTable(fullData);
            pieStatisticBean.setLimitedDataTable(limitedData);
            try
            {
                pieStatisticBean.setPercentages();
View Full Code Here

        return new URL[0];
    }

    public NamedList getStatistics()
    {
        NamedList lst = new SimpleOrderedMap();
        synchronized ( this )
        {
            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", cacheService.entries() );
        }

        lst.add( "warmupTime", warmupTime );

        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

  private void handleAdminRequest(HttpServletRequest req, ServletResponse response, SolrRequestHandler handler,
                                  SolrQueryRequest solrReq) throws IOException {
    SolrQueryResponse solrResp = new SolrQueryResponse();
    final NamedList<Object> responseHeader = new SimpleOrderedMap<Object>();
    solrResp.add("responseHeader", responseHeader);
    NamedList toLog = solrResp.getToLog();
    toLog.add("webapp", req.getContextPath());
    toLog.add("path", solrReq.getContext().get("path"));
    toLog.add("params", "{" + solrReq.getParamString() + "}");
    handler.handleRequest(solrReq, solrResp);
    SolrCore.setResponseHeaderValues(handler, solrReq, solrResp);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < toLog.size(); i++) {
      String name = toLog.getName(i);
      Object val = toLog.getVal(i);
      sb.append(name).append("=").append(val).append(" ");
    }
    QueryResponseWriter respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get(solrReq.getParams().get(CommonParams.WT));
    if (respWriter == null) respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get("standard");
    writeResponse(solrResp, response, respWriter, solrReq, Method.getMethod(req.getMethod()));
View Full Code Here

TOP

Related Classes of org.apache.solr.common.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.