Package org.apache.solr.search

Examples of org.apache.solr.search.DocList


            true);
        int matchOffset = params.getInt(MoreLikeThisParams.MATCH_OFFSET, 0);
        // Find the base match
        Query query = QueryParsing.parseQuery(q, params.get(CommonParams.DF),
            params, req.getSchema());
        DocList match = searcher.getDocList(query, null, null, matchOffset, 1,
            flags); // only get the first one...
        if (includeMatch) {
          rsp.add("match", match);
        }

        // This is an iterator, but we only handle the first match
        DocIterator iterator = match.iterator();
        if (iterator.hasNext()) {
          // do a MoreLikeThis query for each document in results
          int id = iterator.nextDoc();
          mltDocs = mlt.getMoreLikeThis(id, start, rows, filters, interesting,
              flags);
View Full Code Here


  private List<NamedList<Object>> checkEngine(CarrotClusteringEngine engine, int expectedNumDocs,
                           int expectedNumClusters, Query query, SolrParams clusteringParams) throws IOException {
    // Get all documents to cluster
    RefCounted<SolrIndexSearcher> ref = h.getCore().getSearcher();

    DocList docList;
    try {
      SolrIndexSearcher searcher = ref.get();
      docList = searcher.getDocList(query, (Query) null, new Sort(), 0,
              numberOfDocs);
      assertEquals("docList size", expectedNumDocs, docList.matches());

      ModifiableSolrParams solrParams = new ModifiableSolrParams();
      solrParams.add(CarrotParams.PRODUCE_SUMMARY, "true");
      solrParams.add(clusteringParams);

      // Perform clustering
      LocalSolrQueryRequest req = new LocalSolrQueryRequest(h.getCore(), solrParams);
      Map<SolrDocument,Integer> docIds = new HashMap<SolrDocument, Integer>(docList.size());
      SolrDocumentList solrDocList = SolrPluginUtils.docListToSolrDocumentList( docList, searcher, engine.getFieldsToLoad(req), docIds );
     
      @SuppressWarnings("unchecked")
             List<NamedList<Object>> results = (List<NamedList<Object>>) engine.cluster(query, solrDocList, docIds, req);
      req.close();
View Full Code Here

    SolrIndexSearcher.QueryResult qr = new SolrIndexSearcher.QueryResult();
    SolrIndexSearcher.QueryCommand cmd = new SolrIndexSearcher.QueryCommand();
    cmd.setQuery(new MatchAllDocsQuery());
    qr = srchr.search(qr, cmd);

    DocList docs = qr.getDocList();
    Set<String> fields = new HashSet<String>();
    fields.add("val_t");


    SolrDocumentList list = SolrPluginUtils.docListToSolrDocumentList(docs, srchr, fields, null);
    assertTrue("list Size: " + list.size() + " is not: " + docs.size(), list.size() == docs.size());
    for (SolrDocument document : list) {
      assertNotNull(document.get("val_t"));
    }
    holder.decref();
  }
View Full Code Here

    SolrIndexSearcher.QueryResult qr = new SolrIndexSearcher.QueryResult();
    SolrIndexSearcher.QueryCommand cmd = new SolrIndexSearcher.QueryCommand();
    cmd.setQuery(new MatchAllDocsQuery());
    qr = srchr.search(qr, cmd);

    DocList docs = qr.getDocList();
    Set<String> fields = new HashSet<String>();
    fields.add("val_t");


    SolrDocumentList list = SolrPluginUtils.docListToSolrDocumentList(docs, srchr, fields, null);
    assertTrue("list Size: " + list.size() + " is not: " + docs.size(), list.size() == docs.size());
    for (SolrDocument document : list) {
      assertNotNull(document.get("val_t"));
    }

  }
View Full Code Here

  private List checkEngine(CarrotClusteringEngine engine,
                           int expectedNumClusters, SolrParams clusteringParams) throws IOException {
    // Get all documents to cluster
    RefCounted<SolrIndexSearcher> ref = h.getCore().getSearcher();
    MatchAllDocsQuery query = new MatchAllDocsQuery();
    DocList docList;
    try {
      SolrIndexSearcher searcher = ref.get();
      docList = searcher.getDocList(query, (Query) null, new Sort(), 0,
              numberOfDocs);
      assertEquals("docList size", this.numberOfDocs, docList.matches());
    } finally {
      ref.decref();
    }

    ModifiableSolrParams solrParams = new ModifiableSolrParams();
View Full Code Here

      if( ttinfo != null && sfield != null && sfield.indexed() ) {
        Query q = qp.parse( fieldName+":[* TO *]" );
        int docCount = searcher.numDocs( q, matchAllDocs );
        if( docCount > 0 ) {
          // Find a document with this field
          DocList ds = searcher.getDocList( q, (Query)null, (Sort)null, 0, 1 );
          try {
            Document doc = searcher.doc( ds.iterator().next() );
            Fieldable fld = doc.getFieldable( fieldName );
            if( fld != null ) {
              f.add( "index", getFieldFlags( fld ) );
            }
            else {
View Full Code Here

      // Matching options
      boolean includeMatch = params.getBool( MoreLikeThisParams.MATCH_INCLUDE, true );
      int matchOffset = params.getInt( MoreLikeThisParams.MATCH_OFFSET, 0 );
      // Find the base match 
      Query query = QueryParsing.parseQuery(q, params.get(CommonParams.DF), params, req.getSchema());
      DocList match = searcher.getDocList(query, null, null, matchOffset, 1, flags ); // only get the first one...
      if( includeMatch ) {
        rsp.add( "match", match );
      }

      // This is an iterator, but we only handle the first match
      DocIterator iterator = match.iterator();
      if( iterator.hasNext() ) {
        // do a MoreLikeThis query for each document in results
        int id = iterator.nextDoc();
        mltDocs = mlt.getMoreLikeThis( id, start, rows, filters, interesting, flags );
      }
View Full Code Here

        // level values in the NamedList are checked for DocLists.
        NamedList values = rsp.getValues();
        for (int i=0; i<values.size(); i++) {
          Object o = values.getVal(i);
          if (o instanceof DocList) {
            DocList docs = (DocList)o;
            for (DocIterator iter = docs.iterator(); iter.hasNext();) {
              newSearcher.doc(iter.nextDoc());
            }
          }
        }
View Full Code Here

      // Matching options
      boolean includeMatch = params.getBool( MoreLikeThisParams.MATCH_INCLUDE, true );
      int matchOffset = params.getInt( MoreLikeThisParams.MATCH_OFFSET, 0 );
      // Find the base match 
      Query query = QueryParsing.parseQuery(q, params.get(CommonParams.DF), params, req.getSchema());
      DocList match = searcher.getDocList(query, null, null, matchOffset, 1, flags ); // only get the first one...
      if( includeMatch ) {
        rsp.add( "match", match );
      }

      // This is an iterator, but we only handle the first match
      DocIterator iterator = match.iterator();
      if( iterator.hasNext() ) {
        // do a MoreLikeThis query for each document in results
        int id = iterator.nextDoc();
        mltDocs = mlt.getMoreLikeThis( id, start, rows, filters, interesting, flags );
      }
View Full Code Here

    List<Integer> docIds = getInts(params.getParams(TermVectorParams.DOC_IDS));
    Iterator<Integer> iter;
    if (docIds != null && docIds.isEmpty() == false) {
      iter = docIds.iterator();
    } else {
      DocList list = listAndSet.docList;
      iter = list.iterator();
    }
    SolrIndexSearcher searcher = rb.req.getSearcher();

    IndexReader reader = searcher.getReader();
    //the TVMapper is a TermVectorMapper which can be used to optimize loading of Term Vectors
View Full Code Here

TOP

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

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.