Examples of IndexRequest


Examples of org.elasticsearch.action.index.IndexRequest

   
    // TODO Create the bulk
    brb = node.client().prepareBulk();
    for (int i = 0; i < 1000; i++) {
      Beer beer = BeerHelper.generate();
      IndexRequest irq =  null;
     
      // TODO Add the beer to meal index, type beer and set id = "beer_"+i
    }
    BulkResponse br = null;
   
View Full Code Here

Examples of org.elasticsearch.action.index.IndexRequest

    BulkRequestBuilder brb = node.client().prepareBulk();

    for (int i = 0; i < 1000; i++) {
      Beer beer = BeerHelper.generate();
      IndexRequest irq = new IndexRequest("meal", "beer", "beer_" + i);
      String jsonString = mapper.writeValueAsString(beer);
      irq.source(jsonString);
      brb.add(irq);
    }

    BulkResponse br = brb.execute().actionGet();
    Assert.assertFalse(br.hasFailures());
View Full Code Here

Examples of org.elasticsearch.action.index.IndexRequest

                continue;
            }

            try {
                XContentBuilder source = createDoc(o);
                IndexRequest indexReq = Requests.indexRequest(indexName).type(getIndexType()).id(o.getId()).source(source);
               
                if (enableVersioning)
                    indexReq.version(o.getVersion());

                brb.add(indexReq);
            } catch (IOException ex) {
                logger.warn("Cannot add object:" + o + " to bulkIndexing action." + ex.getMessage());
            }
View Full Code Here

Examples of org.elasticsearch.action.index.IndexRequest

      List<Map<String, Object>> comments = extractComments(document);
      if (comments != null && !comments.isEmpty()) {
        String issueKey = extractDocumentId(document);
        for (Map<String, Object> comment : comments) {
          String commentId = extractCommentId(comment);
          IndexRequest irq = indexRequest(indexName).type(commentTypeName).id(commentId)
              .source(prepareCommentIndexedDocument(spaceKey, issueKey, comment));
          if (commentIndexingMode == CommentIndexingMode.CHILD) {
            irq.parent(issueKey);
          }
          esBulk.add(irq);
        }
      }
    }
View Full Code Here

Examples of org.elasticsearch.action.index.IndexRequest

      List<Map<String, Object>> comments = extractComments(document);
      if (comments != null && !comments.isEmpty()) {
        String issueKey = extractDocumentId(document);
        for (Map<String, Object> comment : comments) {
          String commentId = extractCommentId(comment);
          IndexRequest irq = indexRequest(indexName).type(commentTypeName).id(commentId)
              .source(prepareCommentIndexedDocument(spaceKey, issueKey, comment));
          if (commentIndexingMode == CommentIndexingMode.CHILD) {
            irq.parent(issueKey);
          }
          esBulk.add(irq);
        }
      }
    }
View Full Code Here

Examples of org.elasticsearch.action.index.IndexRequest

    private void indexProducts(List<Map<String, Object>> products, String index, String routing) throws Exception {
        long currentCount = getCurrentDocumentCount(index);
        BulkRequest bulkRequest = new BulkRequest();
        for (Map<String, Object> product : products) {
            IndexRequest indexRequest = new IndexRequest(index, "product", (String)product.get("ProductId"));
            indexRequest.source(product);
            if (Strings.hasLength(routing)) {
                indexRequest.routing(routing);
            }
            bulkRequest.add(indexRequest);
        }
        bulkRequest.refresh(true);
        BulkResponse response = client().bulk(bulkRequest).actionGet();
View Full Code Here

Examples of org.elasticsearch.action.index.IndexRequest

                   
                    while (results != null && results.hasMore()) {
                       
                        SearchResult sr = (SearchResult) results.next();
                       
                        IndexRequest indexRequest = new IndexRequest(indexName);
                       
                        XContentBuilder builder = jsonBuilder();
                        builder.startObject();
                       
                        String dn = sr.getName();
                        logger.debug("Reading ldap object dn [{}]", dn);
                       
                        Attributes ldapAttributes = sr.getAttributes();
                        NamingEnumeration<String> ldapAttributesIds = ldapAttributes.getIDs();
                        while (ldapAttributesIds.hasMoreElements()) {
                            String id = ldapAttributesIds.next();
                            logger.debug("\treading attribute id [{}]", id);
                           
                            List<String> fieldValues = new ArrayList<String>();
                            Attribute attribute = ldapAttributes.get(id);
                            NamingEnumeration<?> values = attribute.getAll();
                            while (values.hasMoreElements()) {
                                Object value = values.next();
                                logger.debug("\t\tvalue: [{}]", value.toString());
                                fieldValues.add(value.toString());
                            }
                            String fieldName = resolveFieldName(id);
                            if(fieldValues.size() > 1){
                                builder.array(fieldName, fieldValues.toArray());
                            } else {
                                if (!"_id".equals(fieldName)) {
                                    builder.field(fieldName, fieldValues.get(0));
                                } else {
                                    indexRequest.id(fieldValues.get(0));
                                }
                            }
                        }

                        builder.endObject();
                       
                        indexRequest.type(typeName).source(builder);
                        bulkRequest.add(indexRequest);
                        count++;
                       
                        if((count % bulkSize) == 0){
                            BulkResponse bulkResponse = bulkRequest.execute().actionGet(bulkTimeout);
View Full Code Here

Examples of org.elasticsearch.action.index.IndexRequest

            }
            if (closed) {
                logger.warn("river was closing while trying to index document [{}/{}/{}]. Operation skipped.", index, type, id);
                return null;
            }
            bulkProcessor.add(new IndexRequest(index, type, id).source(doc).routing(extractRouting(ctx)).parent(extractParent(ctx)));
        } else {
            logger.warn("ignoring unknown change {}", s);
        }
        return seq;
    }
View Full Code Here

Examples of org.elasticsearch.action.index.IndexRequest

                        }
                        if (closed) {
                            logger.warn("river was closing while trying to update sequence [{}/{}/{}]. Operation skipped.", riverIndexName, riverName.name(), "_seq");
                            return;
                        }
                        bulkProcessor.add(new IndexRequest(riverIndexName, riverName.name(), "_seq")
                                .source(jsonBuilder().startObject().startObject("couchdb").field("last_seq", lastSeqAsString).endObject().endObject()));
                    } catch (IOException e) {
                        logger.warn("failed to add last_seq entry to bulk indexing");
                    }
                }
View Full Code Here

Examples of org.elasticsearch.action.index.IndexRequest

    IndexQuery indexQuery = getIndexQuery(sampleEntity);

    elasticsearchTemplate.index(indexQuery);
    elasticsearchTemplate.refresh(SampleEntity.class, true);

    IndexRequest indexRequest = new IndexRequest();
    indexRequest.source("message", messageAfterUpdate);
    UpdateQuery updateQuery = new UpdateQueryBuilder().withId(documentId)
        .withClass(SampleEntity.class).withIndexRequest(indexRequest).build();
    // when
    elasticsearchTemplate.update(updateQuery);
    //then
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.