Package org.apache.solr.common.params

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


  }

  @Override
  public void process(ResponseBuilder rb) throws IOException {
    rb.stage = ResponseBuilder.STAGE_START;
    SolrParams params = rb.req.getParams();
    // Set field flags
      String fl = params.get(CommonParams.FL);
      int fieldFlags = 0;
      if (fl != null) {
        fieldFlags |= SolrPluginUtils.setReturnFields(fl, rb.rsp);
      }
      rb.setFieldFlags( fieldFlags );

      String defType = params.get(QueryParsing.DEFTYPE);
      defType = defType==null ? QParserPlugin.DEFAULT_QTYPE : defType;

      String qString = params.get( CommonParams.Q );
      if (qString == null || qString.length()==0){
        qString="*:*";
      }
      if (rb.getQueryString() == null) {
        rb.setQueryString( qString);
      }

      try {
        QParser parser = QParser.getParser(rb.getQueryString(), defType, rb.req);
        rb.setQuery( parser.getQuery() );
        rb.setSortSpec( parser.getSort(true) );
        rb.setQparser(parser);

       
        String[] fqs = params.getParams(CommonParams.FQ);
        if (fqs!=null && fqs.length!=0) {
          List<Query> filters = rb.getFilters();
          if (filters==null) {
            filters = new ArrayList<Query>();
            rb.setFilters( filters );
          }
          for (String fq : fqs) {
            if (fq != null && fq.trim().length()!=0) {
              QParser fqp = QParser.getParser(fq, null, rb.req);
              filters.add(fqp.getQuery());
            }
          }
        } 
      } catch (ParseException e) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
      }
   
    Query query = rb.getQuery();
      SortSpec sortspec = rb.getSortSpec();
      Sort sort = null;
      if (sortspec!=null){
        sort = sortspec.getSort();
      }

      SolrParams solrParams = rb.req.getParams();

    String shardsVal = solrParams.get(ShardParams.SHARDS, null);
   
      BrowseRequest br = null;
      try{
        br=BoboRequestBuilder.buildRequest(solrParams,query,sort);
      }
      catch(Exception e){
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
      }
      BrowseResult res = null;
      if (shardsVal == null && !solrParams.getBool(ShardParams.IS_SHARD, false))
    {

      SolrIndexSearcher searcher=rb.req.getSearcher();
     
      SolrIndexReader solrReader = searcher.getReader();
View Full Code Here


  }
 
  @Override
  protected ModelAndView handleRequestInternal(HttpServletRequest req,
      HttpServletResponse res) throws Exception {
    SolrParams params = new BoboHttpRequestParam(req);
    String qstring = params.get(CommonParams.Q);
    String df = params.get(CommonParams.DF);
    String sortString = params.get(CommonParams.SORT);
    BoboDefaultQueryBuilder qbuilder = new BoboDefaultQueryBuilder();
    Query query = qbuilder.parseQuery(qstring, df);
    Sort sort = qbuilder.parseSort(sortString);
    BrowseRequest br = null;
    try {
View Full Code Here

    }
  }
 
  @Override
  protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    SolrParams params = new BoboHttpRequestParam(req);
    String qstring = params.get(CommonParams.Q);
    String df = params.get(CommonParams.DF);
    String sortString = params.get(CommonParams.SORT);
    BoboDefaultQueryBuilder qbuilder = new BoboDefaultQueryBuilder();
    Query query = qbuilder.parseQuery(qstring, df);
    Sort sort = qbuilder.parseSort(sortString);
    BrowseRequest br = null;
    try {
View Full Code Here

  ExecutorCompletionService<String> submit=new ExecutorCompletionService<String>(SUBMIT_POOL);
  Callable<String> task = new Callable<String>() {
        public String call() throws Exception {

          long t2=System.currentTimeMillis();
          SolrParams params = rb.req.getParams();
          String[] facetFs = params.getParams(FacetParams.FACET_FIELD);

          try{
              if (null != facetFs) {
                boolean isdetail = params.getBool(FacetParams.FACET_CROSS_DETAIL,false);
                 Object res= FacetComponent.this.getResult(isdetail,rb.req.getSearcher(), params,rb.req,facetFs,rb.getResults().docSet);
                  rb.rsp.add( "mdrill_data", res);
              }else{
                throw new Exception("null != facetFs");
              }
View Full Code Here

      log.debug("using default similarity");
    } else {
      final Object obj = loader.newInstance(((Element) node).getAttribute("class"));
      if (obj instanceof SimilarityFactory) {
        // configure a factory, get a similarity back
        SolrParams params = SolrParams.toSolrParams(DOMUtil.childNodesToNamedList(node));
        similarityFactory = (SimilarityFactory)obj;
        similarityFactory.init(params);
      } else {
        // just like always, assume it's a Similarlity and get a ClassCastException - reasonable error handling
        similarityFactory = new SimilarityFactory() {
View Full Code Here

  @Override
  protected void init(IndexSchema schema, Map<String, String> args) {
    this.schema = schema;
    //it's not a first class citizen for the IndexSchema
    SolrParams p = new MapSolrParams(args);
    String subFT = p.get(SUB_FIELD_TYPE);
    String subSuffix = p.get(SUB_FIELD_SUFFIX);
    if (subFT != null) {
      args.remove(SUB_FIELD_TYPE);
      subType = schema.getFieldTypeByName(subFT.trim());
      suffix = POLY_FIELD_SEPARATOR + subType.typeName;
    } else if (subSuffix != null) {
View Full Code Here

public class PluginInfoHandler extends RequestHandlerBase
{
  @Override
  public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
  {
    SolrParams params = req.getParams();
   
    boolean stats = params.getBool( "stats", false );
    rsp.add( "plugins", getSolrInfoBeans( req.getCore(), stats ) );
    rsp.setHttpCaching(false);
  }
View Full Code Here

  int maxNumToLog = 8;
 
  @Override
  public void init( final NamedList args ) {
    if( args != null ) {
      SolrParams params = SolrParams.toSolrParams( args );
      maxNumToLog = params.getInt( "maxNumToLog", maxNumToLog );
    }
  }
View Full Code Here

  private SolrParams params;

  @Override
  public void init(final NamedList args) {
    if (args != null) {
      SolrParams params = SolrParams.toSolrParams(args);
      boolean enabled = params.getBool("enabled", true);
      this.enabled = enabled;

      overwriteDupes = params.getBool("overwriteDupes", true);

      signatureField = params.get("signatureField", "signatureField");

      signatureTerm = new Term(signatureField, "");

      signatureClass = params.get("signatureClass",
          "org.apache.solr.update.processor.Lookup3Signature");
      this.params = params;

      Object fields = args.get("fields");
      sigFields = fields == null ? null: StrUtils.splitSmart((String)fields, ",", true);
View Full Code Here

  public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
  {   
    IndexSchema schema = req.getSchema();
    SolrIndexSearcher searcher = req.getSearcher();
    IndexReader reader = searcher.getReader();
    SolrParams params = req.getParams();
    int numTerms = params.getInt( NUMTERMS, DEFAULT_COUNT );
       
    // Always show the core lucene info
    rsp.add("index", getIndexInfo(reader, numTerms>0 ) );

    Integer docId = params.getInt( DOC_ID );
    if( docId == null && params.get( ID ) != null ) {
      // Look for something with a given solr ID
      SchemaField uniqueKey = schema.getUniqueKeyField();
      String v = uniqueKey.getType().toInternal( params.get(ID) );
      Term t = new Term( uniqueKey.getName(), v );
      docId = searcher.getFirstMatch( t );
      if( docId < 0 ) {
        throw new SolrException( SolrException.ErrorCode.NOT_FOUND, "Can't find document: "+params.get( ID ) );
      }
    }
       
    // Read the document from the index
    if( docId != null ) {
      Document doc = null;
      try {
        doc = reader.document( docId );
      }
      catch( Exception ex ) {}
      if( doc == null ) {
        throw new SolrException( SolrException.ErrorCode.NOT_FOUND, "Can't find document: "+docId );
      }
     
      SimpleOrderedMap<Object> info = getDocumentFieldsInfo( doc, docId, reader, schema );
     
      SimpleOrderedMap<Object> docinfo = new SimpleOrderedMap<Object>();
      docinfo.add( "docId", docId );
      docinfo.add( "lucene", info );
      docinfo.add( "solr", doc );
      rsp.add( "doc", docinfo );
    }
    else if ( "schema".equals( params.get( "show" ) ) ) {
      rsp.add( "schema", getSchemaInfo( req.getSchema() ) );
    }
    else {
      // If no doc is given, show all fields and top terms
      Set<String> fields = null;
      if( params.get( CommonParams.FL ) != null ) {
        fields = new HashSet<String>();
        for( String f : params.getParams( CommonParams.FL ) ) {
          fields.add( f );
        }
      }
      rsp.add( "fields", getIndexedFieldsInfo( searcher, fields, numTerms ) ) ;
    }
View Full Code Here

TOP

Related Classes of org.apache.solr.common.params.SolrParams

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.