Package org.apache.solr.common

Examples of org.apache.solr.common.SolrException


              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();
      BoboIndexReader reader = (BoboIndexReader)solrReader.getWrappedReader();
     
      if (reader instanceof BoboIndexReader){
          try {
            List<Query> filters = rb.getFilters();
            if (filters!=null){
              final ArrayList<DocIdSet> docsets = new ArrayList<DocIdSet>(filters.size());
                for (Query filter : filters){
                  Weight weight = filter.createWeight(rb.req.getSearcher());
                  final Scorer scorer = weight.scorer(reader, false, true);
                  docsets.add(new DocIdSet(){
                @Override
                public DocIdSetIterator iterator() throws IOException {
                  return scorer;
                }
                   
                  });
                }
               
                if (docsets.size()>0){
                  br.setFilter(
                    new Filter(){
                @Override
                public DocIdSet getDocIdSet(IndexReader reader)
                    throws IOException {
                  return new AndDocIdSet(docsets);
                }
                  });
                }
            }
             
            Set<String> facetNames = reader.getFacetNames();
            Set<String> returnFields = rb.rsp.getReturnFields();
            Set<String> storedFields = new HashSet<String>();
            if (returnFields!=null){
              for (String fld : returnFields){
              if (!facetNames.contains(fld)){
                storedFields.add(fld);
              }
              }
              br.setFetchStoredFields(!storedFields.isEmpty());
            }
           
           
                  BoboBrowser browser = new BoboBrowser(reader);
                 
          res=browser.browse(br);
         
        } catch (Exception e) {
          logger.error(e.getMessage(),e);
          throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,e.getMessage(),e);
        }
        
      }
      else{
            throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"invalid reader, please make sure BoboIndexReaderFactory is set.");
      }
    }
    else{
      // multi sharded request
      String[] shards = shardsVal.split(",");
View Full Code Here


        if (!cmd.fromPending && !cmd.fromCommitted)
        {
            numErrors.incrementAndGet();
            numErrorsCumulative.incrementAndGet();
            throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "meaningless command: " + cmd);
        }
        if (!cmd.fromPending || !cmd.fromCommitted)
        {
            numErrors.incrementAndGet();
            numErrorsCumulative.incrementAndGet();
            throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "operation not supported" + cmd);
        }

        Term term = idTerm.createTerm(idFieldType.toInternal(cmd.id));

        if (logger.isDebugEnabled())
View Full Code Here

        if (!cmd.fromPending && !cmd.fromCommitted)
        {
            numErrors.incrementAndGet();
            numErrorsCumulative.incrementAndGet();
            throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "meaningless command: " + cmd);
        }
        if (!cmd.fromPending || !cmd.fromCommitted)
        {
            numErrors.incrementAndGet();
            numErrorsCumulative.incrementAndGet();
            throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "operation not supported" + cmd);
        }

        boolean madeIt = false;

        try
View Full Code Here

      }
      if( s.startsWith("false") || s.startsWith("off") || s.equals("no") ) {
        return false;
      }
    }
    throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "invalid boolean value: "+s );
  }
View Full Code Here

          val = StrUtils.parseBool(textValue);
        }
        // :NOTE: Unexpected Node names are ignored
        // :TODO: should we generate an error here?
      } catch (NumberFormatException nfe) {
        throw new SolrException
          (SolrException.ErrorCode.SERVER_ERROR,
           "Value " + (null != name ? ("of '" +name+ "' ") : "") +
           "can not be parsed as '" +type+ "': \"" + textValue + "\"",
           nfe);
      }
View Full Code Here

        }
        if (fragment == null) {
          fragment = System.getProperty(propertyName, defaultValue);
        }
        if (fragment == null) {
          throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "No system property or default value specified for " + propertyName);
        }
      }
      sb.append(fragment);
    }
    return sb.toString();
View Full Code Here

                DirectXmlRequest xmlRequest = new DirectXmlRequest(getRequestHandler(), bodyAsString);

                solrServer.request(xmlRequest);               
            } else {
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "unable to find data in Exchange to update Solr");
            }
        }
    }
View Full Code Here

   */
  private SynonymMap loadSolrSynonyms(ResourceLoader loader, boolean dedup, Analyzer analyzer) throws IOException, ParseException {
    final boolean expand = getBoolean("expand", true);
    String synonyms = args.get("synonyms");
    if (synonyms == null)
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Missing required argument 'synonyms'.");

    CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder()
            .onMalformedInput(CodingErrorAction.REPORT)
            .onUnmappableCharacter(CodingErrorAction.REPORT);

View Full Code Here

   */
  private SynonymMap loadWordnetSynonyms(ResourceLoader loader, boolean dedup, Analyzer analyzer) throws IOException, ParseException {
    final boolean expand = getBoolean("expand", true);
    String synonyms = args.get("synonyms");
    if (synonyms == null)
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Missing required argument 'synonyms'.");

    CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder()
            .onMalformedInput(CodingErrorAction.REPORT)
            .onUnmappableCharacter(CodingErrorAction.REPORT);

View Full Code Here

  }

  protected String getArg(String n, Map<String,String> args) {
    String s = args.remove(n);
    if (s == null) {
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Missing parameter '"+n+"' for FieldType=" + typeName +args);
    }
    return s;
  }
View Full Code Here

TOP

Related Classes of org.apache.solr.common.SolrException

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.