Examples of UpdateRequest


Examples of org.apache.solr.client.solrj.request.UpdateRequest

   * @param query  the query expressing what documents to delete
   * @throws SolrServerException
   * @throws IOException
   */
  public UpdateResponse deleteByQuery(String query) throws SolrServerException, IOException {
    return new UpdateRequest().deleteByQuery( query ).process( this );
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.request.UpdateRequest

        server.setMaxTotalConnections(100);
        server.setFollowRedirects(false);
        server.setAllowCompression(false);
        server.setMaxRetries(4);
        server.setRequestWriter(new BinaryRequestWriter());
        UpdateRequest req = new UpdateRequest();
        req.add(docs);
        UpdateResponse rsp = req.process(server);
        rtn.put(s, rsp.toString());
        }catch(Throwable e)
        {
          LOG.error("insert error "+url,e);
          throw new Exception(e);
        }
      }

    }else if(tp.equals(FlushType.sync)||tp.equals(FlushType.syncHdfs))
    {
      for(ShardsList write:cores)
      {
        for (String s : write.list) {
          String url = "http://" + s + "/solr/" + projectName;
          try{
          CommonsHttpSolrServer server = new CommonsHttpSolrServer(url);
          server.setConnectionManagerTimeout(60000l);
          server.setSoTimeout(60000);
          server.setConnectionTimeout(10000);
          server.setDefaultMaxConnectionsPerHost(100);
          server.setMaxTotalConnections(100);
          server.setFollowRedirects(false);
          server.setAllowCompression(false);
          server.setMaxRetries(4);
          server.setRequestWriter(new BinaryRequestWriter());
          UpdateRequest req = new UpdateRequest();
          req.add(docs);
          UpdateResponse rsp = req.process(server);
          rtn.put(s, rsp.toString());
          }catch(Throwable e)
          {
            LOG.error("insert error "+url,e);
            throw new Exception(e);          }
View Full Code Here

Examples of org.apache.solr.client.solrj.request.UpdateRequest

   * @param commitWithinMs  the time in milliseconds before a commit automatically is triggered
   * @return the response from the SolrServer
   */
  public UpdateResponse add(Iterator<SolrInputDocument> docIterator, int commitWithinMs)
          throws SolrServerException, IOException {
    UpdateRequest req = new UpdateRequest();
    req.setDocIterator(docIterator);
    req.setCommitWithin(commitWithinMs);
    return req.process(this);
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.request.UpdateRequest

   * @param beanIterator  the iterator which returns Beans
   * @return the response from the SolrServer
   */
  public UpdateResponse addBeans(final Iterator<?> beanIterator, int commitWithinMs)
          throws SolrServerException, IOException {
    UpdateRequest req = new UpdateRequest();
    req.setDocIterator(new Iterator<SolrInputDocument>() {

      public boolean hasNext() {
        return beanIterator.hasNext();
      }

      public SolrInputDocument next() {
        Object o = beanIterator.next();
        if (o == null) return null;
        return getBinder().toSolrInputDocument(o);
      }

      public void remove() {
        beanIterator.remove();
      }
    });
    req.setCommitWithin(commitWithinMs);
    return req.process(this);
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.request.UpdateRequest

public class BinaryRequestWriter extends RequestWriter {

  @Override
  public Collection<ContentStream> getContentStreams(SolrRequest req) throws IOException {
    if (req instanceof UpdateRequest) {
      UpdateRequest updateRequest = (UpdateRequest) req;
      if (isNull(updateRequest.getDocuments()) &&
              isNull(updateRequest.getDeleteById()) &&
              isNull(updateRequest.getDeleteQuery())
              && (updateRequest.getDocIterator() == null) ) {
        return null;
      }
      List<ContentStream> l = new ArrayList<ContentStream>();
      l.add(new LazyContentStream(updateRequest));
      return l;
View Full Code Here

Examples of org.apache.solr.client.solrj.request.UpdateRequest


  @Override
  public void write(SolrRequest request, OutputStream os) throws IOException {
    if (request instanceof UpdateRequest) {
      UpdateRequest updateRequest = (UpdateRequest) request;
      new JavaBinUpdateRequestCodec().marshal(updateRequest, os);
    }

  }/*
 
View Full Code Here

Examples of org.apache.solr.client.solrj.request.UpdateRequest

  public NamedList<Object> request( final SolrRequest request ) throws SolrServerException, IOException
  {
    if( !(request instanceof UpdateRequest) ) {
      return super.request( request );
    }
    UpdateRequest req = (UpdateRequest)request;
   
    // this happens for commit...
    if( req.getDocuments()==null || req.getDocuments().isEmpty() ) {
      blockUntilFinished();
      return super.request( request );
    }

    SolrParams params = req.getParams();
    if( params != null ) {
      // check if it is waiting for the searcher
      if( params.getBool( UpdateParams.WAIT_SEARCHER, false ) ) {
        log.info( "blocking for commit/optimize" );
        blockUntilFinished()// empty the queue
View Full Code Here

Examples of org.apache.solr.client.solrj.request.UpdateRequest

     
              public void writeRequest(OutputStream out) throws IOException {
                try {
                  OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
                  writer.append( "<stream>" ); // can be anything...
                  UpdateRequest req = queue.poll( 250, TimeUnit.MILLISECONDS );
                  while( req != null ) {
                    log.debug( "sending: {}" , req );
                    req.writeXML( writer );
                   
                    // check for commit or optimize
                    SolrParams params = req.getParams();
                    if( params != null ) {
                      String fmt = null;
                      if( params.getBool( UpdateParams.OPTIMIZE, false ) ) {
                        fmt = "<optimize waitSearcher=\"%s\" waitFlush=\"%s\" />";
                      }
View Full Code Here

Examples of org.apache.solr.client.solrj.request.UpdateRequest

  /**
   * Add a document.
   */
  public void add(final SolrInputDocument doc)
  throws SolrServerException, IOException {
    final UpdateRequest request = new UpdateRequest();
    request.add(doc);
    request.process(this.getServer());
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.request.UpdateRequest

        // Do the operation!
        long fullStartTime = System.currentTimeMillis();
        // Open a socket to ingest, and to the response stream to get the post result
        try
        {
          UpdateResponse response = new UpdateRequest(postRemoveAction).deleteById(documentURI).process(solrServer);
           
          // Success
          activityStart = new Long(fullStartTime);
          activityCode = "OK";
          activityDetails = null;
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.