当前位置: 首页>>代码示例>>Java>>正文


Java ContentStreamUpdateRequest.setAction方法代码示例

本文整理汇总了Java中org.apache.solr.client.solrj.request.ContentStreamUpdateRequest.setAction方法的典型用法代码示例。如果您正苦于以下问题:Java ContentStreamUpdateRequest.setAction方法的具体用法?Java ContentStreamUpdateRequest.setAction怎么用?Java ContentStreamUpdateRequest.setAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.client.solrj.request.ContentStreamUpdateRequest的用法示例。


在下文中一共展示了ContentStreamUpdateRequest.setAction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testContentStreamRequest

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
@Test
public void testContentStreamRequest() throws Exception {
   SolrServer server = getSolrServer();
   server.deleteByQuery( "*:*" );// delete everything!
   server.commit();
   QueryResponse rsp = server.query( new SolrQuery( "*:*") );
   Assert.assertEquals( 0, rsp.getResults().getNumFound() );

   ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");
   up.addFile(getFile("solrj/books.csv"), "application/csv");
   up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
   NamedList<Object> result = server.request(up);
   assertNotNull("Couldn't upload books.csv", result);
   rsp = server.query( new SolrQuery( "*:*") );
   Assert.assertEquals( 10, rsp.getResults().getNumFound() );
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:SolrExampleTests.java

示例2: testMultiContentStreamRequest

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
@Test
public void testMultiContentStreamRequest() throws Exception {
   SolrServer server = getSolrServer();
   server.deleteByQuery( "*:*" );// delete everything!
   server.commit();
   QueryResponse rsp = server.query( new SolrQuery( "*:*") );
   Assert.assertEquals( 0, rsp.getResults().getNumFound() );

   ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");
   up.addFile(getFile("solrj/docs1.xml"),"application/xml"); // 2
   up.addFile(getFile("solrj/docs2.xml"),"application/xml"); // 3
   up.setParam("a", "\u1234");
   up.setParam(CommonParams.HEADER_ECHO_PARAMS, CommonParams.EchoParamStyle.ALL.toString());
   up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
   NamedList<Object> result = server.request(up);
   Assert.assertEquals("\u1234",
       ((NamedList)((NamedList) result.get("responseHeader")).get("params")).get("a"));
   assertNotNull("Couldn't upload xml files", result);
   rsp = server.query( new SolrQuery( "*:*") );
   Assert.assertEquals( 5 , rsp.getResults().getNumFound() );
 }
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:SolrExampleTests.java

示例3: testNumberOfCommitsWithCommitAfterAdd

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
private void testNumberOfCommitsWithCommitAfterAdd()
    throws SolrServerException, IOException {
  log.info("### STARTING testNumberOfCommitsWithCommitAfterAdd");
  long startCommits = getNumCommits((HttpSolrServer) clients.get(0));
  
  ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");
  up.addFile(getFile("books_numeric_ids.csv"), "application/csv");
  up.setCommitWithin(900000);
  up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
  NamedList<Object> result = clients.get(0).request(up);
  
  long endCommits = getNumCommits((HttpSolrServer) clients.get(0));

  assertEquals(startCommits + 1L, endCommits);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:16,代码来源:BasicDistributedZkTest.java

示例4: addDoc

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
@Override
  public void addDoc(final SSDBNoSQLAddDocPar par) throws SSErr {
    
//    according to Solr specification by adding a document with an ID already
//	  existing in the index will replace the document (eg. refer to 
//	  http://stackoverflow.com/questions/8494923/solr-block-updating-of-existing-document or
//	  http://lucene.apache.org/solr/api-4_0_0-ALPHA/doc-files/tutorial.html ) 
   
    try{
      final ContentStreamUpdateRequest csur = new ContentStreamUpdateRequest("/update/extract");
      final NamedList<Object>          response;

      csur.addContentStream(new ContentStreamBase.FileStream(new File(SSConf.getLocalWorkPath() + par.id)));

      csur.setParam  ("literal.id",  par.id);
//      csur.setParam  ("stream.type", "application/octet-stream");
      
      csur.setAction (AbstractUpdateRequest.ACTION.COMMIT, true, true);

      response = solrServer.request(csur);

      SSLogU.info("document w/ id " + par.id + " added successfully. ");
    }catch(Exception error){
      SSServErrReg.regErrThrow(error);
    }
  }
 
开发者ID:learning-layers,项目名称:SocialSemanticServer,代码行数:27,代码来源:SSDBNoSQLSolrImpl.java

示例5: add

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
@Override
public void add(String path, Map<String, Object> data, ResourceBinary binary) throws IndexException {

    if (binary == null) {
        add(path, data);
        return;
    }

    ContentStreamUpdateRequest request = new ContentStreamUpdateRequest("/update/extract");
    request.addContentStream(new AssetContentStream(binary));
    request.setParam("literal.id", buildId(path));
    Set<String> fields = data.keySet();
    for (String field : fields) {
        if (field.equals(this.idField)) {
            throw new IndexException("ID field must not get populated through data fields.");
        }
        Object fieldValue = data.get(field);
        if (fieldValue != null) {
            if (fieldValue instanceof Collection) {
                Collection<?> fieldValues = (Collection) fieldValue;
                for (Object value : fieldValues) {
                    // TODO deal with numeric & date type values (format to string)
                    request.setParam("literal." + field, valueToString(value));
                }
            } else {
                // assume it's one of the supported data types
                request.setParam("literal." + field, valueToString(fieldValue));
            }
        }
    }
    request.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
    try {
        solrServer.request(request);
    } catch (Exception e) {
        throw new IndexException(e);
    }
}
 
开发者ID:mwmd,项目名称:ease,代码行数:38,代码来源:SolrIndexServer.java


注:本文中的org.apache.solr.client.solrj.request.ContentStreamUpdateRequest.setAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。