Package org.apache.solr.common

Examples of org.apache.solr.common.SolrInputDocument


     
      public static void main(String[] args) {
       
        for(int k=0;k<1000;k++)
        {
        SolrInputDocument dd=new SolrInputDocument();
        dd.addField("a", 1);
        dd.addField("b", 1.0);
        dd.addField("c", "1123");
        dd.addField("d", 1l);
        dd.addField("c", "333");
        dd.addField("c", "1111000000000000000000001111");

        dd.addField("e", "4");

        dd.addField("d"+k, k);


        byte[] bytes=ser(dd);

        System.out.println(serialize(dd).length+"=="+bytes.length);
        SolrInputDocument aaa=dec(bytes);

        System.out.println(aaa.toString());
       
        System.out.println("#######################");
        }
  }
View Full Code Here


            } catch (Throwable e) {
              LOG.error("readOp", e);
              break;
            }
           
            SolrInputDocument doc=op.getDoc();
            doc.setTxid(op.getTransactionId());
            if(lines<100000)
            {
              lines++;
              if(lines%500==0)
              {
                LOG.info("##recover##"+doc.toString()+",savedTxid="+savedTxid+":"+this.params.getLogStr());
              }
            }
            allrecord++;
            if(allrecord%1000==0)
            {
View Full Code Here

            } catch (Throwable e) {
              LOG.error("readOp", e);
              break;
            }
           
            SolrInputDocument doc=op.getDoc();
            doc.setTxid(op.getTransactionId());
            if(lines<100000)
            {
              lines++;
              if(lines%500==0)
              {
                LOG.info("##recover##"+doc.toString()+",savedTxid="+savedTxid+":"+this.params.getLogStr());
              }
            }
            allrecord++;
            if(allrecord%1000==0)
            {
View Full Code Here

    }
  }

  @Override
  public void processAdd(AddUpdateCommand cmd) throws IOException {
    SolrInputDocument doc = cmd.getSolrInputDocument();
    classifyDocument(doc);
    super.processAdd(cmd);
  }
View Full Code Here

      contentSource.setConfig(new Config(properties));
      contentSource.resetInputs();
      //docMaker.openFile();
      List<SolrInputDocument> docs = new ArrayList<SolrInputDocument>(1000);
      int i = 0;
      SolrInputDocument sDoc = null;
      long start = System.currentTimeMillis();
      try {
        DocData docData = new DocData();

        while ((docData = contentSource.getNextDocData(docData)) != null && i < numDocs) {
          int mod = i % batchSize;

          sDoc = new SolrInputDocument();
          docs.add(sDoc);
          sDoc.addField("file", filePath + "_" + i);

          sDoc.addField("docid", String.valueOf(i));
          sDoc.addField("body", docData.getBody());
          sDoc.addField("doctitle", docData.getTitle());
          sDoc.addField("name_s", docData.getName());


          if (mod == batchSize - 1) {
            log.info("Sending: " + docs.size() + " docs" + " total sent for this file: " + i);
            server.add(docs);
View Full Code Here

      contentSource.setConfig(new Config(properties));
      contentSource.resetInputs();
      // docMaker.openFile();
      List<SolrInputDocument> docs = new ArrayList<SolrInputDocument>(1000);
      int i = 0;
      SolrInputDocument sDoc = null;
      long start = System.currentTimeMillis();
      try {
        DocData docData = new DocData();
       
        while ((docData = contentSource.getNextDocData(docData)) != null
            && i < numDocs) {
          int mod = i % batchSize;
         
          sDoc = new SolrInputDocument();
          docs.add(sDoc);
          sDoc.addField("file", filePath + "_" + i);
         
          sDoc.addField("docid", String.valueOf(docData.getID()));
          sDoc.addField("body", docData.getBody());
          sDoc.addField("doctitle", docData.getTitle());
          sDoc.addField("name_s", docData.getName());
         
          String[] categories = docData.getProps().getProperty("category")
              .split(";;");
         
          for (String c : categories) {
            sDoc.addField("category", c);
          }
         
          if (mod == batchSize - 1) {
            log.info("Sending: " + docs.size() + " docs"
                + " total sent for this file: " + i);
View Full Code Here

   *  <li> <code>json</code> containing the serialised JSON object
   * </ul>
   */
  private SolrInputDocument parseObject(final String object)
  throws JsonProcessingException, IOException {
    final SolrInputDocument doc = new SolrInputDocument();
    final JsonNode node = mapper.readTree(object);
    doc.addField("id", node.path("ChargeDeviceId").asText());
    doc.addField("name", node.path("ChargeDeviceName").asText());
    doc.addField("DeviceController_facet", node.path("DeviceController").path("OrganisationName").asText());
    doc.addField("json", node);
    return doc;
  }
View Full Code Here

  protected void addJsonFileWoCommit(final String id, final String path)
  throws IOException, SolrServerException {
    final FileReader reader = new FileReader(path);
    try {
      final String content = IOUtils.toString(reader);
      final SolrInputDocument document = new SolrInputDocument();
      document.addField(ID_FIELD, id);
      document.addField(JSON_FIELD, content);
      getWrapper().add(document);
    }
    finally {
      reader.close();
    }
View Full Code Here

  }

  protected void addJsonStringWoCommit(final String id, final String field,
                                       final String content)
  throws IOException, SolrServerException {
    final SolrInputDocument document = new SolrInputDocument();
    document.addField(ID_FIELD, id);
    document.addField(field, content);
    getWrapper().add(document);
  }
View Full Code Here

    initCore("solrconfig.xml", "schema-multifield.xml", SOLR_HOME);
  }

  @Test
  public void testMultiFieldQuery() throws SolrServerException, IOException {
    SolrInputDocument document = new SolrInputDocument();
    document.addField(ID_FIELD, "1");
    document.addField(JSON_FIELD + 1, "{ \"aaa\" : \"bbb\" }");
    document.addField(JSON_FIELD + 2, "{ \"aaa\" : \"ccc\" }");
    getWrapper().add(document);

    document = new SolrInputDocument();
    document.addField(ID_FIELD, "2");
    document.addField(JSON_FIELD + 1, "{ \"aaa\" : \"ccc\" }");
    document.addField(JSON_FIELD + 2, "{ \"aaa\" : \"bbb\" }");
    getWrapper().add(document);

    getWrapper().commit();

    final SolrQuery query = new SolrQuery();
View Full Code Here

TOP

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

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.