Package org.apache.solr.common

Examples of org.apache.solr.common.SolrInputDocument


        return null; // no need to recurse down the removed subtree
    }

    private SolrInputDocument docFromState(NodeState state) {
        SolrInputDocument inputDocument = new SolrInputDocument();
        String path = getPath();
        if (!path.endsWith("/")) {
            path = path + "/";
        }
        inputDocument.addField(configuration.getPathField(), path);
        for (PropertyState property : state.getProperties()) {
            // try to get the field to use for this property from configuration
            String fieldName = configuration.getFieldNameFor(property.getType());
            if (fieldName != null) {
                inputDocument.addField(
                        fieldName, property.getValue(property.getType()));
            } else {
                // or fallback to adding propertyName:stringValue(s)
                if (property.isArray()) {
                    for (String s : property.getValue(Type.STRINGS)) {
                        inputDocument.addField(property.getName(), s);
                    }
                } else {
                    inputDocument.addField(
                            property.getName(), property.getValue(Type.STRING));
                }
            }
        }
        return inputDocument;
View Full Code Here



    @DirtiesContext
    @Test
    public void endToEndIndexDirectXML() throws Exception {
        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("id", "MA147LL/A", 1.0f);
        String docAsXml = ClientUtils.toXML(doc);
        directXmlRoute.sendBody(docAsXml);

        QueryResponse response = executeSolrQuery("id:MA147LL/A");
        assertEquals(0, response.getStatus());
View Full Code Here

            if (hasSolrHeaders) {

                UpdateRequest updateRequest = new UpdateRequest(getRequestHandler());

                SolrInputDocument doc = new SolrInputDocument();
                for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
                    if (entry.getKey().startsWith(SolrConstants.FIELD)) {
                        String fieldName = entry.getKey().substring(SolrConstants.FIELD.length());
                        doc.setField(fieldName, entry.getValue());
                    }
                }
                updateRequest.add(doc);

                if (isStreaming) {
View Full Code Here

        return null; // no need to recurse down the removed subtree
    }

    private SolrInputDocument docFromState(NodeState state) {
        SolrInputDocument inputDocument = new SolrInputDocument();
        String path = getPath();
        if (!path.endsWith("/")) {
            path = path + "/";
        }
        inputDocument.addField(configuration.getPathField(), path);
        for (PropertyState property : state.getProperties()) {
            // try to get the field to use for this property from configuration
            String fieldName = configuration.getFieldNameFor(property.getType());
            if (fieldName != null) {
                inputDocument.addField(
                        fieldName, property.getValue(property.getType()));
            } else {
                // or fallback to adding propertyName:stringValue(s)
                if (property.isArray()) {
                    for (String s : property.getValue(Type.STRINGS)) {
                        inputDocument.addField(property.getName(), s);
                    }
                } else {
                    inputDocument.addField(
                            property.getName(), property.getValue(Type.STRING));
                }
            }
        }
        return inputDocument;
View Full Code Here

       
        try {
            SolrServer solrServer = this.getSolrClient();
            for (int i = 0; i < indexDocuments.size(); i++) {
                Map<String, Object> indexDocument = indexDocuments.get(i);
                SolrInputDocument solrInputDocument = new SolrInputDocument();
                for (Object obj : indexDocument.keySet()) {
                    String key = String.valueOf(obj);
                    // 建立solr文档
                    Object value = indexDocument.get(key);
                    solrInputDocument.addField(key, value);
                }
                solrServer.add(solrInputDocument);
            }
           
            solrServer.optimize();
View Full Code Here

        return null; // no need to recurse down the removed subtree
    }

    private SolrInputDocument docFromState(NodeState state) {
        SolrInputDocument inputDocument = new SolrInputDocument();
        String path = getPath();
        if (!path.endsWith("/")) {
            path = path + "/";
        }
        inputDocument.addField(configuration.getPathField(), path);
        for (PropertyState property : state.getProperties()) {
            // try to get the field to use for this property from configuration
            String fieldName = configuration.getFieldNameFor(property.getType());
            if (fieldName != null) {
                inputDocument.addField(
                        fieldName, property.getValue(property.getType()));
            } else {
                // or fallback to adding propertyName:stringValue(s)
                if (property.isArray()) {
                    for (String s : property.getValue(Type.STRINGS)) {
                        inputDocument.addField(property.getName(), s);
                    }
                } else {
                    inputDocument.addField(
                            property.getName(), property.getValue(Type.STRING));
                }
            }
        }
        return inputDocument;
View Full Code Here

    public void update(NutchDocument doc) throws IOException {
        write(doc);
    }

    public void write(NutchDocument doc) throws IOException {
        final SolrInputDocument inputDoc = new SolrInputDocument();
        for (final Entry<String, NutchField> e : doc) {
            for (final Object val : e.getValue().getValues()) {
                // normalise the string representation for a Date
                Object val2 = val;

                if (val instanceof Date) {
                    val2 = DateUtil.getThreadLocalDateFormat().format(val);
                }

                if (e.getKey().equals("content") || e.getKey().equals("title")) {
                    val2 = SolrUtils.stripNonCharCodepoints((String) val);
                }

                inputDoc.addField(solrMapping.mapKey(e.getKey()), val2, e
                        .getValue().getWeight());
                String sCopy = solrMapping.mapCopyKey(e.getKey());
                if (sCopy != e.getKey()) {
                    inputDoc.addField(sCopy, val);
                }
            }
        }

        inputDoc.setDocumentBoost(doc.getWeight());
        inputDocs.add(inputDoc);
        if (inputDocs.size() + numDeletes >= batchSize) {
            try {
                LOG.info("Indexing " + Integer.toString(inputDocs.size())
                        + " documents");
View Full Code Here

  @Override
  public void processAdd(AddUpdateCommand cmd) throws IOException {
    String text = null;
    try {
      /* get Solr document */
      SolrInputDocument solrInputDocument = cmd.getSolrInputDocument();

      /* get the fields to analyze */
      String[] texts = getTextsToAnalyze(solrInputDocument);
      for (int i = 0; i < texts.length; i++) {
        text = texts[i];
View Full Code Here

  @Override
  public void processAdd(AddUpdateCommand cmd) throws IOException {
    String text = null;
    try {
      /* get Solr document */
      SolrInputDocument solrInputDocument = cmd.getSolrInputDocument();

      /* get the fields to analyze */
      String[] texts = getTextsToAnalyze(solrInputDocument);
      for (int i = 0; i < texts.length; i++) {
        text = texts[i];
View Full Code Here

  /*
   * @see org.apache.droids.api.Handler#handle(java.net.URI, org.apache.droids.api.ContentEntity)
   */
    @Override
  public void handle(URI uri, ContentEntity entity) throws IOException, DroidsException {
    SolrInputDocument doc = createSolrInputDocument(uri, entity);
    try {
      server.add(doc);
    } catch (SolrServerException e) {
      throw new DroidsException(e);
    }
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.