Examples of SolrParams


Examples of org.apache.solr.common.params.SolrParams

  }

  @Override
  public SpellingResult getSuggestions(SpellingOptions options) throws IOException {
    boolean shardRequest = false;
    SolrParams params = options.customParams;
    if(params!=null)
    {
      shardRequest = "true".equals(params.get(ShardParams.IS_SHARD));
    }
    SpellingResult result = new SpellingResult(options.tokens);
    IndexReader reader = determineReader(options.reader);
    Term term = field != null ? new Term(field, "") : null;
    float theAccuracy = (options.accuracy == Float.MIN_VALUE) ? spellChecker.getAccuracy() : options.accuracy;
View Full Code Here

Examples of org.apache.solr.common.params.SolrParams

  public static final String TERM_VECTORS = "termVectors";


  @Override
  public void process(ResponseBuilder rb) throws IOException {
    SolrParams params = rb.req.getParams();
    if (!params.getBool(COMPONENT_NAME, false)) {
      return;
    }

    NamedList<Object> termVectors = new NamedList<Object>();
    rb.rsp.add(TERM_VECTORS, termVectors);
    FieldOptions allFields = new FieldOptions();
    //figure out what options we have, and try to get the appropriate vector
    allFields.termFreq = params.getBool(TermVectorParams.TF, false);
    allFields.positions = params.getBool(TermVectorParams.POSITIONS, false);
    allFields.offsets = params.getBool(TermVectorParams.OFFSETS, false);
    allFields.docFreq = params.getBool(TermVectorParams.DF, false);
    allFields.tfIdf = params.getBool(TermVectorParams.TF_IDF, false);
    //boolean cacheIdf = params.getBool(TermVectorParams.IDF, false);
    //short cut to all values.
    boolean all = params.getBool(TermVectorParams.ALL, false);
    if (all == true) {
      allFields.termFreq = true;
      allFields.positions = true;
      allFields.offsets = true;
      allFields.docFreq = true;
      allFields.tfIdf = true;
    }

    String fldLst = params.get(TermVectorParams.FIELDS);
    if (fldLst == null) {
      fldLst = params.get(CommonParams.FL);
    }

    //use this to validate our fields
    IndexSchema schema = rb.req.getSchema();
    //Build up our per field mapping
    Map<String, FieldOptions> fieldOptions = new HashMap<String, FieldOptions>();
    NamedList<List<String>>  warnings = new NamedList<List<String>> ();
    List<String>  noTV = new ArrayList<String>();
    List<String>  noPos = new ArrayList<String>();
    List<String>  noOff = new ArrayList<String>();

    //we have specific fields to retrieve
    if (fldLst != null) {
      String [] fields = SolrPluginUtils.split(fldLst);
      for (String field : fields) {
        SchemaField sf = schema.getFieldOrNull(field);
        if (sf != null) {
          if (sf.storeTermVector()) {
            FieldOptions option = fieldOptions.get(field);
            if (option == null) {
              option = new FieldOptions();
              option.fieldName = field;
              fieldOptions.put(field, option);
            }
            //get the per field mappings
            option.termFreq = params.getFieldBool(field, TermVectorParams.TF, allFields.termFreq);
            option.docFreq = params.getFieldBool(field, TermVectorParams.DF, allFields.docFreq);
            option.tfIdf = params.getFieldBool(field, TermVectorParams.TF_IDF, allFields.tfIdf);
            //Validate these are even an option
            option.positions = params.getFieldBool(field, TermVectorParams.POSITIONS, allFields.positions);
            if (option.positions && !sf.storeTermPositions()){
              noPos.add(field);
            }
            option.offsets = params.getFieldBool(field, TermVectorParams.OFFSETS, allFields.offsets);
            if (option.offsets && !sf.storeTermOffsets()){
              noOff.add(field);
            }
          } else {//field doesn't have term vectors
            noTV.add(field);
          }
        } else {
          //field doesn't exist
          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "undefined field: " + field);
        }
      }
    } //else, deal with all fields
    boolean hasWarnings = false;
    if (!noTV.isEmpty()) {
      warnings.add("noTermVectors", noTV);
      hasWarnings = true;
    }
    if (!noPos.isEmpty()) {
      warnings.add("noPositions", noPos);
      hasWarnings = true;
    }
    if (!noOff.isEmpty()) {
      warnings.add("noOffsets", noOff);
      hasWarnings = true;
    }
    if (hasWarnings) {
      termVectors.add("warnings", warnings);
    }

    DocListAndSet listAndSet = rb.getResults();
    List<Integer> docIds = getInts(params.getParams(TermVectorParams.DOC_IDS));
    Iterator<Integer> iter;
    if (docIds != null && !docIds.isEmpty()) {
      iter = docIds.iterator();
    } else {
      DocList list = listAndSet.docList;
View Full Code Here

Examples of org.apache.solr.common.params.SolrParams

      NamedList toLog = rsp.getToLog();
      // for back compat, we set these now just in case other code
      // are expecting them during handleRequest
      toLog.add("webapp", req.getContext().get("webapp"));
      toLog.add("path", req.getContext().get("path"));
      SolrParams params=req.getParams();
      NamedList<Object> p=params.toNamedList();
      p.remove("mdrill.crc.key.get.crclist");
      toLog.add("params", "{" + p.toString() + "}");
      StringBuilder sb = new StringBuilder(logid);
      for (int i=0; i<toLog.size(); i++) {
        String name = toLog.getName(i);
View Full Code Here

Examples of org.apache.solr.common.params.SolrParams

    responseHeader.add("status",status);
    responseHeader.add("QTime",qtime);
    rsp.getToLog().add("status",status);
    rsp.getToLog().add("QTime",qtime);
   
    SolrParams params = req.getParams();
    if( params.getBool(CommonParams.HEADER_ECHO_HANDLER, false) ) {
      responseHeader.add("handler", handler.getName() );
    }
   
    // Values for echoParams... false/true/all or false/explicit/all ???
    String ep = params.get( CommonParams.HEADER_ECHO_PARAMS, null );
    if( ep != null ) {
      EchoParamStyle echoParams = EchoParamStyle.get( ep );
      if( echoParams == null ) {
        throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Invalid value '" + ep + "' for " + CommonParams.HEADER_ECHO_PARAMS
            + " parameter, use '" + EchoParamStyle.EXPLICIT + "' or '" + EchoParamStyle.ALL + "'" );
View Full Code Here

Examples of org.apache.solr.common.params.SolrParams

   *
   * @return AnalysisRequest containing all the information about what needs to be analyzed, and using what
   *         fields/types
   */
  FieldAnalysisRequest resolveAnalysisRequest(SolrQueryRequest req) {
    SolrParams solrParams = req.getParams();
    FieldAnalysisRequest analysisRequest = new FieldAnalysisRequest();

    boolean useDefaultSearchField = true;
    if (solrParams.get(AnalysisParams.FIELD_TYPE) != null) {
      analysisRequest.setFieldTypes(Arrays.asList(solrParams.get(AnalysisParams.FIELD_TYPE).split(",")));
      useDefaultSearchField = false;
    }
    if (solrParams.get(AnalysisParams.FIELD_NAME) != null) {
      analysisRequest.setFieldNames(Arrays.asList(solrParams.get(AnalysisParams.FIELD_NAME).split(",")));
      useDefaultSearchField = false;
    }
    if (useDefaultSearchField)  {
      analysisRequest.addFieldName(req.getSchema().getDefaultSearchFieldName());
    }
    analysisRequest.setQuery(solrParams.get(AnalysisParams.QUERY, solrParams.get(CommonParams.Q)));

    String value = solrParams.get(AnalysisParams.FIELD_VALUE);

    Iterable<ContentStream> streams = req.getContentStreams();
    if (streams != null) {
      // NOTE: Only the first content stream is currently processed
      for (ContentStream stream : streams) {
        Reader reader = null;
        try {
          reader = stream.getReader();
          value = IOUtils.toString(reader);
        } catch (IOException e) {
          // do nothing, leave value set to the request parameter
        }
        finally {
          IOUtils.closeQuietly(reader);
        }
        break;
      }
    }

    analysisRequest.setFieldValue(value);
    analysisRequest.setShowMatch(solrParams.getBool(AnalysisParams.SHOW_MATCH, false));
    return analysisRequest;
  }
View Full Code Here

Examples of org.apache.solr.common.params.SolrParams

    rb.setDebug(false);//清理用不到的debug

    for( SearchComponent c : components ) {
        c.prepare(rb);
      }
    SolrParams paramsr=req.getParams();
    String shards = paramsr.get(ShardParams.SHARDS);

    if (shards == null) {
   for( SearchComponent c : components ) {
         c.process(rb);
       }
     return ;
    }
   
   

    String mergeServers=paramsr.get(FacetParams.MERGER_SERVERS);
  List<String> lst = StrUtils.splitSmart(shards, ",", true);
  List<String> mslist = StrUtils.splitSmart(mergeServers, ",", true);

    String[] partions=paramsr.getParams(ShardParams.PARTIONS);
   
    ScheduleInfo scheduleInfo=MergerSchedule.schedule(paramsr, lst, mslist,partions);
   
   
    int depth=req.getParams().getInt("__higo_ms_depth__", 0);
View Full Code Here

Examples of org.apache.solr.common.params.SolrParams

  protected QParser altQParser;


  @Override
  public Query parse() throws ParseException {
    SolrParams solrParams = localParams == null ? params : new DefaultSolrParams(localParams, params);
    queryFields = SolrPluginUtils.parseFieldBoosts(solrParams.getParams(DisMaxParams.QF));
    if (0 == queryFields.size()) {
      queryFields.put(req.getSchema().getDefaultSearchFieldName(), 1.0f);
    }
   
    /* the main query we will execute.  we disable the coord because
View Full Code Here

Examples of org.apache.solr.common.params.SolrParams

  }

  @Override
  public void process(ResponseBuilder rb) throws IOException
  {
    SolrParams p = rb.req.getParams();
    if( p.getBool( MoreLikeThisParams.MLT, false ) ) {
      SolrIndexSearcher searcher = rb.req.getSearcher();
     
      NamedList<DocList> sim = getMoreLikeThese( rb, searcher,
          rb.getResults().docList, rb.getFieldFlags() );
View Full Code Here

Examples of org.apache.solr.common.params.SolrParams

    }
  }

  NamedList<DocList> getMoreLikeThese( ResponseBuilder rb, SolrIndexSearcher searcher,
      DocList docs, int flags ) throws IOException {
    SolrParams p = rb.req.getParams();
    IndexSchema schema = searcher.getSchema();
    MoreLikeThisHandler.MoreLikeThisHelper mltHelper
      = new MoreLikeThisHandler.MoreLikeThisHelper( p, searcher );
    NamedList<DocList> mlt = new SimpleOrderedMap<DocList>();
    DocIterator iterator = docs.iterator();

    SimpleOrderedMap<Object> dbg = null;
    if( rb.isDebug() ){
      dbg = new SimpleOrderedMap<Object>();
    }

    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 ){
View Full Code Here

Examples of org.apache.solr.common.params.SolrParams

   * @since solr 1.2
   */
  @Deprecated
  public static boolean handleCommit( SolrQueryRequest req, SolrQueryResponse rsp, boolean force ) throws IOException
  {
    SolrParams params = req.getParams();
    if( params == null ) {
      params = new MapSolrParams( new HashMap<String, String>() );
    }
   
    boolean optimize = params.getBool( UpdateParams.OPTIMIZE, false );
    boolean commit   = params.getBool( UpdateParams.COMMIT,   false );
   
    if( optimize || commit || force ) {
      CommitUpdateCommand cmd = new CommitUpdateCommand( optimize );
      cmd.waitFlush    = params.getBool( UpdateParams.WAIT_FLUSH,    cmd.waitFlush    );
      cmd.waitSearcher = params.getBool( UpdateParams.WAIT_SEARCHER, cmd.waitSearcher );
      cmd.expungeDeletes = params.getBool( UpdateParams.EXPUNGE_DELETES, cmd.expungeDeletes);
      cmd.maxOptimizeSegments = params.getInt(UpdateParams.MAX_OPTIMIZE_SEGMENTS, cmd.maxOptimizeSegments);
      req.getCore().getUpdateHandler().commit( cmd );
     
      // Lets wait till after solr1.2 to define consistent output format
      //if( optimize ) {
      //  rsp.add( "optimize", true );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.