Package org.apache.solr.search

Examples of org.apache.solr.search.DocListAndSet


      rawMLTQuery = mlt.like(reader);
      boostedMLTQuery = getBoostedQuery( rawMLTQuery );
      if( terms != null ) {
        fillInterestingTermsFromMLTQuery( boostedMLTQuery, terms );
      }
      DocListAndSet results = new DocListAndSet();
      if (this.needDocSet) {
        results = searcher.getDocListAndSet( boostedMLTQuery, filters, null, start, rows, flags);
      } else {
        results.docList = searcher.getDocList( boostedMLTQuery, filters, null, start, rows, flags);
      }
View Full Code Here


      NamedList<DocList> mlt = new SimpleOrderedMap<DocList>();
      DocIterator iterator = docs.iterator();
      while( iterator.hasNext() ) {
        int id = iterator.nextDoc();
       
        DocListAndSet sim = getMoreLikeThis( id, 0, rows, null, null, flags );
        String name = schema.printableUniqueKey( reader.document( id ) );

        mlt.add(name, sim.docList);
      }
      return mlt;
View Full Code Here

    }

    while( iterator.hasNext() ) {
      int id = iterator.nextDoc();
      int rows = p.getInt( MoreLikeThisParams.DOC_COUNT, 5 );
      DocListAndSet sim = mltHelper.getMoreLikeThis( id, 0, rows, null, null, flags );
      String name = schema.printableUniqueKey( searcher.doc( id ) );
      mlt.add(name, sim.docList);
     
      if( dbg != null ){
        SimpleOrderedMap<Object> docDbg = new SimpleOrderedMap<Object>();
View Full Code Here

    }

    int start = params.getInt( CommonParams.START, 0 );
    int rows  = params.getInt( CommonParams.ROWS, 10 );
   
    DocListAndSet mltDocs = null;
   
    // Find documents MoreLikeThis - either with a reader or a query
    //--------------------------------------------------------------------------------
    if( reader != null ) {
      mltDocs = mlt.getMoreLikeThis( reader, start, rows, filters, interesting, flags );
    }
    else if( q != null ) {
      // 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 );
      }
    }
    else {
      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
          "MoreLikeThis requires either a query (?q=) or text to find similar documents." );
    }
    if( mltDocs == null ) {
      mltDocs = new DocListAndSet(); // avoid NPE
    }
    rsp.add( "response", mltDocs.docList );
   
 
    if( interesting != null ) {
View Full Code Here

      mltQuery.add(mltquery, BooleanClause.Occur.MUST);
      mltQuery.add(
          new TermQuery(new Term(uniqueKeyField.getName(), doc.get(uniqueKeyField.getName()))),
            BooleanClause.Occur.MUST_NOT);
     
      DocListAndSet results = new DocListAndSet();
      if (this.needDocSet) {
        results = searcher.getDocListAndSet(mltQuery, filters, null, start, rows, flags);
      } else {
        results.docList = searcher.getDocList(mltQuery, filters, null, start, rows, flags);
      }
View Full Code Here

      mltquery = mlt.like(reader);
      setBoosts(mltquery);
      if( terms != null ) {
        fillInterestingTermsFromMLTQuery( mltquery, terms );
      }
      DocListAndSet results = new DocListAndSet();
      if (this.needDocSet) {
        results = searcher.getDocListAndSet(mltquery, filters, null, start, rows, flags);
      } else {
        results.docList = searcher.getDocList(mltquery, filters, null, start, rows, flags);
      }
View Full Code Here

      NamedList<DocList> mlt = new SimpleOrderedMap<DocList>();
      DocIterator iterator = docs.iterator();
      while( iterator.hasNext() ) {
        int id = iterator.nextDoc();
       
        DocListAndSet sim = getMoreLikeThis( id, 0, rows, null, null, flags );
        String name = schema.printableUniqueKey( reader.document( id ) );

        mlt.add(name, sim.docList);
      }
      return mlt;
View Full Code Here

    }

    int start = params.getInt( CommonParams.START, 0 );
    int rows  = params.getInt( CommonParams.ROWS, 10 );
   
    DocListAndSet mltDocs = null;
   
    // Find documents MoreLikeThis - either with a reader or a query
    //--------------------------------------------------------------------------------
    if( reader != null ) {
      mltDocs = mlt.getMoreLikeThis( reader, start, rows, filters, interesting, flags );
    }
    else if( q != null ) {
      // 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 );
      }
    }
    else {
      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
          "MoreLikeThis requires either a query (?q=) or text to find similar documents." );
    }
    if( mltDocs == null ) {
      mltDocs = new DocListAndSet(); // avoid NPE
    }
    rsp.add( "response", mltDocs.docList );
   
 
    if( interesting != null ) {
View Full Code Here

    String[] fields = params.getParams(TermVectorParams.FIELDS);
    if (fields == null) {
      fields = params.getParams(CommonParams.FL);
    }
    DocListAndSet listAndSet = rb.getResults();
    List<Integer> docIds = getInts(params.getParams(TermVectorParams.DOC_IDS));
    Iterator<Integer> iter;
    if (docIds != null && docIds.isEmpty() == false) {
      iter = docIds.iterator();
    } else {
View Full Code Here

      mltQuery.add(mltquery, BooleanClause.Occur.MUST);
      mltQuery.add(
          new TermQuery(new Term(uniqueKeyField.getName(), uniqueKeyField.getType().storedToIndexed(doc.getFieldable(uniqueKeyField.getName())))),
            BooleanClause.Occur.MUST_NOT);
     
      DocListAndSet results = new DocListAndSet();
      if (this.needDocSet) {
        results = searcher.getDocListAndSet(mltQuery, filters, null, start, rows, flags);
      } else {
        results.docList = searcher.getDocList(mltQuery, filters, null, start, rows, flags);
      }
View Full Code Here

TOP

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

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.