Package org.elasticsearch.action.index

Examples of org.elasticsearch.action.index.IndexRequestBuilder


            storeParents(docBuilder, getParents(dspaceObject));

            docBuilder.endObject();

            if (docBuilder != null) {
                IndexRequestBuilder irb = client.prepareIndex(indexName, indexType)
                        .setSource(docBuilder);
                //log.info("Executing document insert into index");
                if(client == null) {
                    log.error("Hey, client is null");
                }
                irb.execute().actionGet();
            }

        } catch (RuntimeException re) {
            log.error("RunTimer in ESL:\n" + ExceptionUtils.getStackTrace(re));
            throw re;
View Full Code Here


            storeParents(docBuilder, getParents(dspaceObject));

            docBuilder.endObject();

            if (docBuilder != null) {
                IndexRequestBuilder irb = client.prepareIndex(indexName, indexType)
                        .setSource(docBuilder);
                //log.info("Executing document insert into index");
                if(client == null) {
                    log.error("Hey, client is null");
                }
                irb.execute().actionGet();
            }

        } catch (RuntimeException re) {
            log.error("RunTimer in ESL:\n" + ExceptionUtils.getStackTrace(re));
            throw re;
View Full Code Here

      public ListenableActionFuture<BulkResponse> execute(Client client, String indexName, OperationContext helper) {
        BulkRequestBuilder request = client.prepareBulk();

        for (Object o : iterable) {
          TypeMapping mapping = helper.findTypeMapping(o);
          IndexRequestBuilder index = mapping.indexRequest(client, indexName, o);
          if (index != null) {
            request.add(index);
          }
        }
View Full Code Here

    @Override
    public ListenableActionFuture<IndexResponse> execute(Client client, String indexName, OperationContext helper) {
      final TypeMapping typeMapping = helper.findTypeMapping(_object);

      IndexRequestBuilder request = typeMapping.indexRequest(client, indexName, _object);
      if (request == null) {
        throw new Esi4JObjectFilteredException(typeMapping, _object);
      } else {
        return request.execute();
      }
    }
View Full Code Here

      String indexName = isBlank(query.getIndexName()) ? retrieveIndexNameFromPersistentEntity(query.getObject()
          .getClass())[0] : query.getIndexName();
      String type = isBlank(query.getType()) ? retrieveTypeFromPersistentEntity(query.getObject().getClass())[0]
          : query.getType();

      IndexRequestBuilder indexRequestBuilder = null;

      if (query.getObject() != null) {
        String entityId = null;
        if (isDocument(query.getObject().getClass())) {
          entityId = getPersistentEntityId(query.getObject());
        }
        // If we have a query id and a document id, do not ask ES to generate one.
        if (query.getId() != null && entityId != null) {
          indexRequestBuilder = client.prepareIndex(indexName, type, query.getId());
        } else {
          indexRequestBuilder = client.prepareIndex(indexName, type);
        }
        indexRequestBuilder.setSource(resultsMapper.getEntityMapper().mapToString(query.getObject()));
      } else if (query.getSource() != null) {
        indexRequestBuilder = client.prepareIndex(indexName, type, query.getId()).setSource(query.getSource());
      } else {
        throw new ElasticsearchException("object or source is null, failed to index the document [id: " + query.getId() + "]");
      }
      if (query.getVersion() != null) {
        indexRequestBuilder.setVersion(query.getVersion());
        indexRequestBuilder.setVersionType(EXTERNAL);
      }

      if (query.getParentId() != null) {
        indexRequestBuilder.setParent(query.getParentId());
      }

      return indexRequestBuilder;
    } catch (IOException e) {
      throw new ElasticsearchException("failed to index the document [id: " + query.getId() + "]", e);
View Full Code Here

    if (so == null || StringUtils.isBlank(appid)) {
      return;
    }
    Map<String, Object> data = Utils.getAnnotatedFields(so);
    try {
      IndexRequestBuilder irb = client().prepareIndex(appid,
          so.getType(), so.getId()).setSource(data);
      if (ttl > 0) {
        irb.setTTL(ttl);
      }
      irb.execute().actionGet();
      logger.debug("Search.index() {}", so.getId());
    } catch (Exception e) {
      logger.warn(null, e);
    }
  }
View Full Code Here

    if (so == null || StringUtils.isBlank(appid)) {
      return;
    }
    Map<String, Object> data = Utils.getAnnotatedFields(so);
    try {
      IndexRequestBuilder irb = client().prepareIndex(appid,
          so.getType(), so.getId()).setSource(data);
      if (ttl > 0) {
        irb.setTTL(ttl);
      }
      irb.execute().actionGet();
      logger.debug("Search.index() {}", so.getId());
    } catch (Exception e) {
      logger.warn(null, e);
    }
  }
View Full Code Here

        for (T object : collection) {
            String id = adapter.id(object);
            try {
                XContentBuilder source = adapter.toJson(object);
                IndexRequestBuilder indexRequest = client().prepareIndex(indexName(type), type, id).setSource(source);
                request.add(indexRequest);

            } catch (IOException e) {
                log.error("The " + type + " of id " + id + " wasn't indexed", e);
            }
View Full Code Here

    doReturn(builder).when(entityDao).getShape(iteratorMocked, 1);

    BulkRequestBuilder bulkRequestBuilderMocked = mock(BulkRequestBuilder.class);
    when(clientMocked.prepareBulk()).thenReturn(bulkRequestBuilderMocked);

    IndexRequestBuilder indexRequestBuilderMocked = mock(IndexRequestBuilder.class);
    when(indexRequestBuilderMocked.setSource(any(String.class))).thenReturn(indexRequestBuilderMocked);
    when(clientMocked.prepareIndex(any(String.class), any(String.class), any(String.class)))
        .thenReturn(indexRequestBuilderMocked);

    // Action
    entityDao.saveAllNodes(Arrays.asList(node));
View Full Code Here

    doReturn(builder).when(entityDao).getShape(iteratorMocked, 4);

    BulkRequestBuilder bulkRequestBuilderMocked = mock(BulkRequestBuilder.class);
    when(clientMocked.prepareBulk()).thenReturn(bulkRequestBuilderMocked);

    IndexRequestBuilder indexRequestBuilderMocked = mock(IndexRequestBuilder.class);
    when(indexRequestBuilderMocked.setSource(any(String.class))).thenReturn(indexRequestBuilderMocked);
    when(clientMocked.prepareIndex(any(String.class), any(String.class), any(String.class)))
        .thenReturn(indexRequestBuilderMocked);

    // Action
    List<Way> ways = Arrays.asList(way);
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.index.IndexRequestBuilder

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.