Package org.apache.solr.search

Examples of org.apache.solr.search.DocSlice


      for (int i=startRow; i<endRow; i++) {
        ids[i] = scoreDocs[i].doc;
        data[i] = req.getSearcher().doc(ids[i]);
      }

      rsp.add(null, new DocSlice(0,numRows,ids,null,numHits,0.0f,
                  0.0f, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));

      /***********************
      rsp.setResults(new DocSlice(0,numRows,ids,null,numHits));

View Full Code Here


    }
    //TODO: Handle group by results
    Object docs = response.getValues().get("response");
    if (docs != null) {
      if (docs instanceof DocSlice) {
        DocSlice doc_slice = (DocSlice) docs;
        results_found = doc_slice.matches();
        start = doc_slice.offset();
      } else {
        SolrDocumentList doc_list = (SolrDocumentList) docs;
        results_found = doc_list.getNumFound();
        start = doc_list.getStart();
      }
View Full Code Here

      String snippet = getValue(sdoc, snippetField);
      // TODO: docIds will be null when running distributed search.
      // See comment in ClusteringComponent#finishStage().
      if (produceSummary && docIds != null) {
        docsHolder[0] = docIds.get(sdoc).intValue();
        DocList docAsList = new DocSlice(0, 1, docsHolder, scores, 1, 1.0f);
        NamedList<Object> highlights = highlighter.doHighlighting(docAsList, theQuery, req, snippetFieldAry);
        if (highlights != null && highlights.size() == 1) {//should only be one value given our setup
          //should only be one document with one field
          @SuppressWarnings("unchecked")
          NamedList<String []> tmp = (NamedList<String[]>) highlights.getVal(0);
View Full Code Here

      for (int i=startRow; i<endRow; i++) {
        ids[i] = scoreDocs[i].doc;
        data[i] = req.getSearcher().doc(ids[i]);
      }

      rsp.add(null, new DocSlice(0,numRows,ids,null,numHits,0.0f));

      /***********************
      rsp.setResults(new DocSlice(0,numRows,ids,null,numHits));

      // Setting the actual document objects is optional
View Full Code Here

      for (int i=startRow; i<endRow; i++) {
        ids[i] = hits.id(i);
        data[i] = hits.doc(i);
      }

      rsp.add(null, new DocSlice(0,numRows,ids,null,numHits,0.0f));

      /***********************
      rsp.setResults(new DocSlice(0,numRows,ids,null,numHits));

      // Setting the actual document objects is optional
View Full Code Here

      for (int i=startRow; i<endRow; i++) {
        ids[i] = hits.id(i);
        data[i] = hits.doc(i);
      }

      rsp.add(null, new DocSlice(0,numRows,ids,null,numHits,0.0f));

      /***********************
      rsp.setResults(new DocSlice(0,numRows,ids,null,numHits));

      // Setting the actual document objects is optional
View Full Code Here

    }

    Object docs = response.getValues().get("response");
    if (docs != null) {
      if (docs instanceof DocSlice) {
        DocSlice doc_slice = (DocSlice) docs;
        results_found = doc_slice.matches();
        start = doc_slice.offset();
      } else {
        SolrDocumentList doc_list = (SolrDocumentList) docs;
        results_found = doc_list.getNumFound();
        start = doc_list.getStart();
      }
View Full Code Here

      for (int i=startRow; i<endRow; i++) {
        ids[i] = hits.id(i);
        data[i] = hits.doc(i);
      }

      rsp.add(null, new DocSlice(0,numRows,ids,null,numHits,0.0f));

      /***********************
      rsp.setResults(new DocSlice(0,numRows,ids,null,numHits));

      // Setting the actual document objects is optional
View Full Code Here

      // we are indexing docId as solr uniq_id. by doing this, we are
      // bound to INTEGER.MAX_VALUE ~= 2 billion
      // docs is number of docs
      DocListAndSet res = new DocListAndSet();
      res.docList = new DocSlice(0, docs, luceneIds, null, docs, 0, null);
      if (rb.isNeedDocSet()) {
        List<Query> queries = new ArrayList<Query>();
        queries.add(rb.getQuery());
        List<Query> filters = rb.getFilters();
        if (filters != null)
          queries.addAll(filters);
        res.docSet = searcher.getDocSet(queries);
      }
      rb.setResults(res);
      rsp.add("response", rb.getResults().docList);
      return;
    }

    SolrIndexSearcher.QueryCommand cmd = rb.getQueryCommand();
    cmd.setTimeAllowed(timeAllowed);
    SolrIndexSearcher.QueryResult result = new SolrIndexSearcher.QueryResult();
   
    searcher.search(result, cmd);
   
    rb.setResult(result);

    rsp.add("response", rb.getResults().docList);
    rsp.getToLog().add("hits", rb.getResults().docList.matches());

    // The query cache doesn't currently store sort field values, and
    // SolrIndexSearcher doesn't
    // currently have an option to return sort field values. Because of
    // this, we
    // take the documents given and re-derive the sort values.
    boolean fsv = req.getParams().getBool(ResponseBuilder.FIELD_SORT_VALUES, false);
    if (fsv) {
      Sort sort = rb.getSortSpec().getSort();
      SortField[] sortFields = sort == null ? new SortField[] { SortField.FIELD_SCORE } : sort.getSort();
      NamedList sortVals = new NamedList(); // order is important for the
                          // sort fields
      Field field = new Field("dummy", "", Field.Store.YES, Field.Index.NO); // a
                                          // dummy
                                          // Field

      SolrIndexReader reader = searcher.getReader();
      SolrIndexReader[] readers = reader.getLeafReaders();
      SolrIndexReader subReader = reader;
      if (readers.length == 1) {
        // if there is a single segment, use that subReader and avoid
        // looking up each time
        subReader = readers[0];
        readers = null;
      }
      int[] offsets = reader.getLeafOffsets();

     
      //TODO: need to fetch sort value from collector instead of re-derive lookup from id
      for (SortField sortField : sortFields) {
        int type = sortField.getType();
        if (type == SortField.SCORE || type == SortField.DOC)
          continue;

        FieldComparator comparator = null;
        FieldComparator comparators[] = (readers == null) ? null : new FieldComparator[readers.length];

        String fieldname = sortField.getField();
        FieldType ft = fieldname == null ? null : req.getSchema().getFieldTypeNoEx(fieldname);

        DocSlice docList = (DocSlice)rb.getResults().docList;
       
        ArrayList<Object> vals = new ArrayList<Object>(docList.size());
        for (int i = docList.offset; i < docList.len; i++) {
          vals.add(new Integer(docList.sorts[i][((EmbeddedSortField)sortField).getFieldNumber() - 1]));
        }

        sortVals.add(fieldname, vals);
View Full Code Here

    // the difference between count and length is the number of duplicates
    int duplicates = length - count;

    int totalMatches = getTotalMatches(searchResultList) - duplicates;

    return new DocSlice(0, count, docList, scoreList, totalMatches, maxScore);
  }
View Full Code Here

TOP

Related Classes of org.apache.solr.search.DocSlice

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.