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


Java ContentStreamUpdateRequest.setParam方法代码示例

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


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

示例1: 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

示例2: index

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
public void index() throws IOException, SolrServerException {
    long tStart = System.currentTimeMillis();
    ContentStreamUpdateRequest updateRequest = new ContentStreamUpdateRequest(UPDATE_PATH);
    updateRequest.addContentStream(getStream());
    if (STYLESHEET.length() > 0) {
        updateRequest.setParam("tr", STYLESHEET);
    }
    updateRequest.setCommitWithin(getCommitWithin());
    NamedList<Object> request = getSolrClient().request(updateRequest);
    if (LOGGER.isDebugEnabled()) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("Solr: indexing data of \"");
        stringBuilder.append(this);
        stringBuilder.append("\" (");
        stringBuilder.append((System.currentTimeMillis() - tStart));
        stringBuilder.append("ms)");
        for (Map.Entry<String, Object> entry : request) {
            stringBuilder.append('\n');
            stringBuilder.append(entry.getKey());
            stringBuilder.append('=');
            stringBuilder.append(entry.getValue());
        }
        LOGGER.debug(stringBuilder.toString());
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:26,代码来源:MCRSolrObjectStreamIndexHandler.java

示例3: testAddCustomJsonWithContentStreamUpdateRequest

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
@Test
public void testAddCustomJsonWithContentStreamUpdateRequest() throws IOException {
    ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(
            "/update/json/docs");
    request.setParam("json.command", "false");
    request.setParam("split", "/exams");
    request.getParams().add("f", "first:/first");
    request.getParams().add("f", "last:/last");
    request.getParams().add("f", "grade:/grade");
    request.getParams().add("f", "subject:/exams/subject");
    request.getParams().add("f", "test:/exams/test");
    request.getParams().add("f", "marks:/exams/marks");

    request.addContentStream(new ContentStreamBase.StringStream(EXAMPLE_JSON));

    runUpdateRequestTest(request, EXPECTED_SOLR_DOCS);
}
 
开发者ID:bbende,项目名称:solrj-custom-json-update,代码行数:18,代码来源:IndexJSONTest.java

示例4: testAddMultipleContentStreamsWithContentStreamUpdateRequest

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
@Test
public void testAddMultipleContentStreamsWithContentStreamUpdateRequest() throws IOException {
    ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(
            "/update/json/docs");
    request.setParam("json.command", "false");
    request.setParam("split", "/exams");
    request.getParams().add("f", "first:/first");
    request.getParams().add("f", "last:/last");
    request.getParams().add("f", "grade:/grade");
    request.getParams().add("f", "subject:/exams/subject");
    request.getParams().add("f", "test:/exams/test");
    request.getParams().add("f", "marks:/exams/marks");

    // add two streams...
    request.addContentStream(new ContentStreamBase.StringStream(EXAMPLE_JSON));
    request.addContentStream(new ContentStreamBase.StringStream(EXAMPLE_JSON2));

    // ensure docs from both streams were added
    Collection<SolrDocument> solrDocuments = new ArrayList<>();
    solrDocuments.addAll(EXPECTED_SOLR_DOCS);
    solrDocuments.addAll(EXPECTED_SOLR_DOCS2);

    runUpdateRequestTest(request, solrDocuments);
}
 
开发者ID:bbende,项目名称:solrj-custom-json-update,代码行数:25,代码来源:IndexJSONTest.java

示例5: testAddMultipleJsonDocsWithContentStreamUpdateRequest

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
@Test
public void testAddMultipleJsonDocsWithContentStreamUpdateRequest() throws IOException {
    ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(
            "/update/json/docs");
    request.setParam("json.command", "false");
    request.setParam("split", "/exams");
    request.getParams().add("f", "first:/first");
    request.getParams().add("f", "last:/last");
    request.getParams().add("f", "grade:/grade");
    request.getParams().add("f", "subject:/exams/subject");
    request.getParams().add("f", "test:/exams/test");
    request.getParams().add("f", "marks:/exams/marks");

    // add one stream with two documents...
    final String jsonWithTwoDocs = "[" + EXAMPLE_JSON + "," + EXAMPLE_JSON2 + "]";
    //final String jsonWithTwoDocs = EXAMPLE_JSON + EXAMPLE_JSON2;
    request.addContentStream(new ContentStreamBase.StringStream(jsonWithTwoDocs));

    // ensure both docs were added
    Collection<SolrDocument> solrDocuments = new ArrayList<>();
    solrDocuments.addAll(EXPECTED_SOLR_DOCS);
    solrDocuments.addAll(EXPECTED_SOLR_DOCS2);

    runUpdateRequestTest(request, solrDocuments);
}
 
开发者ID:bbende,项目名称:solrj-custom-json-update,代码行数:26,代码来源:IndexJSONTest.java

示例6: testAddMultipleFlatJsonDocsSplitTopLevel

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
@Test
public void testAddMultipleFlatJsonDocsSplitTopLevel()
        throws IOException, SolrServerException {

    ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(
            "/update/json/docs");
    request.setParam("json.command", "false");
    request.setParam("split", "/");

    request.addContentStream(new ContentStreamBase.StringStream(JSON_FLAT));

    // should get two documents added
    QueryResponse qResponse = getQueryResponse(request);
    Assert.assertEquals(2, qResponse.getResults().getNumFound());

    for (SolrDocument solrDocument : qResponse.getResults()) {
        System.out.println(solrDocument);

        // each document should have field1 and field2, plus required fields of id and _version_
        Assert.assertEquals(4, solrDocument.getFieldNames().size());
        Assert.assertTrue(solrDocument.containsKey("id"));
        Assert.assertTrue(solrDocument.containsKey("_version_"));
        Assert.assertTrue(solrDocument.containsKey("field1"));
        Assert.assertTrue(solrDocument.containsKey("field2"));
    }
}
 
开发者ID:bbende,项目名称:solrj-custom-json-update,代码行数:27,代码来源:IndexJSONSchemalessTest.java

示例7: 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

示例8: testAddMultipleJsonDocsWithNestingSplitTopLevel

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
@Test
public void testAddMultipleJsonDocsWithNestingSplitTopLevel()
        throws IOException, SolrServerException {

    ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(
            "/update/json/docs");
    request.setParam("json.command", "false");
    request.setParam("split", "/");

    request.addContentStream(new ContentStreamBase.StringStream(JSON_NESTING));

    // should get 2 documents back because we split on /
    QueryResponse qResponse = getQueryResponse(request);
    Assert.assertEquals(2, qResponse.getResults().getNumFound());

    for (SolrDocument solrDocument : qResponse.getResults()) {
        System.out.println(solrDocument);

        // each document should have field1, field2.nested_field1, and field2.nested_field2
        // plus required fields of id and _version_
        Assert.assertEquals(5, solrDocument.getFieldNames().size());
        Assert.assertTrue(solrDocument.containsKey("id"));
        Assert.assertTrue(solrDocument.containsKey("_version_"));
        Assert.assertTrue(solrDocument.containsKey("field1"));
        Assert.assertTrue(solrDocument.containsKey("field2.nested_field1"));
        Assert.assertTrue(solrDocument.containsKey("field2.nested_field2"));

        // field2.nested_field1 should have 2 values since we split at the top-level
        Assert.assertEquals(2, solrDocument.getFieldValues("field2.nested_field1").size());

        // field2.nested_field2 should have 2 values since we split at the top-level
        Assert.assertEquals(2, solrDocument.getFieldValues("field2.nested_field2").size());
    }
}
 
开发者ID:bbende,项目名称:solrj-custom-json-update,代码行数:35,代码来源:IndexJSONSchemalessTest.java

示例9: testAddMultipleJsonDocsWithNestingSplitOnNestedDocs

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
@Test
public void testAddMultipleJsonDocsWithNestingSplitOnNestedDocs()
        throws IOException, SolrServerException {

    ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(
            "/update/json/docs");
    request.setParam("json.command", "false");
    request.setParam("split", "/field2");

    request.addContentStream(new ContentStreamBase.StringStream(JSON_NESTING));

    // should get 4 documents back because we split on field2
    QueryResponse qResponse = getQueryResponse(request);
    Assert.assertEquals(4, qResponse.getResults().getNumFound());

    for (SolrDocument solrDocument : qResponse.getResults()) {
        System.out.println(solrDocument);

        // each document should have field1, field2.nested_field1, and field2.nested_field2
        // plus required fields of id and _version_
        Assert.assertEquals(5, solrDocument.getFieldNames().size());
        Assert.assertTrue(solrDocument.containsKey("id"));
        Assert.assertTrue(solrDocument.containsKey("_version_"));
        Assert.assertTrue(solrDocument.containsKey("field1"));
        Assert.assertTrue(solrDocument.containsKey("field2.nested_field1"));
        Assert.assertTrue(solrDocument.containsKey("field2.nested_field2"));

        // field2.nested_field1 should have 1 value since we split on field2
        Assert.assertEquals(1, solrDocument.getFieldValues("field2.nested_field1").size());

        // field2.nested_field2 should have 1 value since we split on field2
        Assert.assertEquals(1, solrDocument.getFieldValues("field2.nested_field2").size());
    }
}
 
开发者ID:bbende,项目名称:solrj-custom-json-update,代码行数:35,代码来源:IndexJSONSchemalessTest.java

示例10: 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.setParam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。