@Override public void addElement(Graph graph, Element element, Authorizations authorizations) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("addElement: " + element.getId()); } if (!getConfig().isIndexEdges() && element instanceof Edge) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("skipping edge: " + element.getId()); } return; } IndexInfo indexInfo = addPropertiesToIndex(element, element.getProperties()); try { BulkRequest bulkRequest = new BulkRequest(); addElementToBulkRequest(graph, bulkRequest, indexInfo, element, authorizations); if (bulkRequest.numberOfActions() > 0) { doBulkRequest(bulkRequest); if (getConfig().isAutoFlush()) { flush(); } } } catch (Exception e) { throw new SecureGraphException("Could not add element", e); } getConfig().getScoringStrategy().addElement(this, graph, element, authorizations); }
totalCount++; totalCount += getConfig().getScoringStrategy().addElement(this, graph, bulkRequestWithCount, indexInfo, element, authorizations);
@Override public void addElement(Graph graph, Element element, Authorizations authorizations) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("addElement: " + element.getId()); } if (!getConfig().isIndexEdges() && element instanceof Edge) { return; } IndexInfo indexInfo = addPropertiesToIndex(element, element.getProperties()); try { XContentBuilder jsonBuilder = buildJsonContentFromElement(graph, indexInfo, element, authorizations); IndexResponse response = getClient() .prepareIndex(indexInfo.getIndexName(), ElasticSearchSearchIndexBase.ELEMENT_TYPE, element.getId()) .setSource(jsonBuilder.endObject()) .execute() .actionGet(); if (response.getId() == null) { throw new SecureGraphException("Could not index document " + element.getId()); } if (getConfig().isAutoFlush()) { flush(); } } catch (Exception e) { throw new SecureGraphException("Could not add element", e); } getConfig().getScoringStrategy().addElement(this, graph, element, authorizations); }
@Override public void addElement(Graph graph, Element element, Authorizations authorizations) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("addElement: " + element.getId()); } if (!getConfig().isIndexEdges() && element instanceof Edge) { return; } IndexInfo indexInfo = addPropertiesToIndex(element, element.getProperties()); try { XContentBuilder jsonBuilder = buildJsonContentFromElement(graph, indexInfo, element, authorizations); IndexResponse response = getClient() .prepareIndex(indexInfo.getIndexName(), ElasticSearchSearchIndexBase.ELEMENT_TYPE, element.getId()) .setSource(jsonBuilder.endObject()) .execute() .actionGet(); if (response.getId() == null) { throw new SecureGraphException("Could not index document " + element.getId()); } if (getConfig().isAutoFlush()) { flush(); } } catch (Exception e) { throw new SecureGraphException("Could not add element", e); } getConfig().getScoringStrategy().addElement(this, graph, element, authorizations); }