@Override public List<String> getFieldNames() { List<String> fieldNames = super.getFieldNames(); fieldNames.add(EdgeCountScoringStrategyConfiguration.IN_EDGE_COUNT_FIELD_NAME); fieldNames.add(EdgeCountScoringStrategyConfiguration.OUT_EDGE_COUNT_FIELD_NAME); return fieldNames; }
if (getConfig().getScoringStrategy().addFieldsToVertexDocument(this, jsonBuilder, (Vertex) element, existingParentDocument, authorizations)) { changed = true; if (getConfig().getScoringStrategy().addFieldsToEdgeDocument(this, jsonBuilder, (Edge) element, existingParentDocument, authorizations)) { changed = true;
@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); }
protected void createIndexAddFieldsToElementType(XContentBuilder builder) throws IOException { builder .startObject(ELEMENT_TYPE_FIELD_NAME).field("type", "string").field("store", "true").endObject() .startObject(VISIBILITY_FIELD_NAME).field("type", "string").field("analyzer", "keyword").field("index", "not_analyzed").field("store", "true").endObject() ; getConfig().getScoringStrategy().addFieldsToElementType(builder); }
private SearchResponse getSearchResponse(String elementType) { List<FilterBuilder> filters = getFilters(elementType); QueryBuilder query = createQuery(getParameters().getQueryString(), elementType, filters); query = scoringStrategy.updateQuery(query); SearchRequestBuilder q = getSearchRequestBuilder(filters, query); LOGGER.debug("query: " + q); return q.execute() .actionGet(); }
getConfig().getScoringStrategy().addFieldsToVertexDocument(this, jsonBuilder, (Vertex) element, null, authorizations); } else if (element instanceof Edge) { jsonBuilder.field(ElasticSearchSearchIndexBase.ELEMENT_TYPE_FIELD_NAME, ElasticSearchSearchIndexBase.ELEMENT_TYPE_EDGE); getConfig().getScoringStrategy().addFieldsToEdgeDocument(this, jsonBuilder, (Edge) element, null, authorizations); } else { throw new SecureGraphException("Unexpected element type " + element.getClass().getName());
totalCount++; totalCount += getConfig().getScoringStrategy().addElement(this, graph, bulkRequestWithCount, indexInfo, element, authorizations);
protected void createIndexAddFieldsToElementType(XContentBuilder builder) throws IOException { builder .startObject(ELEMENT_TYPE_FIELD_NAME).field("type", "string").field("store", "true").endObject() .startObject(VISIBILITY_FIELD_NAME).field("type", "string").field("analyzer", "keyword").field("index", "not_analyzed").field("store", "true").endObject() ; getConfig().getScoringStrategy().addFieldsToElementType(builder); }
private SearchResponse getSearchResponse(String elementType) { List<FilterBuilder> filters = getFilters(elementType); QueryBuilder query = createQuery(getParameters().getQueryString(), elementType, filters); query = scoringStrategy.updateQuery(query); SearchRequestBuilder q = getSearchRequestBuilder(filters, query); LOGGER.debug("query: " + q); return q.execute() .actionGet(); }
getConfig().getScoringStrategy().addFieldsToVertexDocument(this, jsonBuilder, (Vertex) element, null, authorizations); } else if (element instanceof Edge) { jsonBuilder.field(ElasticSearchSearchIndexBase.ELEMENT_TYPE_FIELD_NAME, ElasticSearchSearchIndexBase.ELEMENT_TYPE_EDGE); getConfig().getScoringStrategy().addFieldsToEdgeDocument(this, jsonBuilder, (Edge) element, null, authorizations); } else { throw new SecureGraphException("Unexpected element type " + element.getClass().getName());
@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 List<String> getFieldNames() { List<String> fieldNames = super.getFieldNames(); fieldNames.add(EdgeCountScoringStrategyConfiguration.IN_EDGE_COUNT_FIELD_NAME); fieldNames.add(EdgeCountScoringStrategyConfiguration.OUT_EDGE_COUNT_FIELD_NAME); return fieldNames; }
@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); }
private String[] getParentDocumentFields() { if (this.parentDocumentFields == null) { List<String> fields = new ArrayList<>(); fields.add(ElasticSearchSearchIndexBase.ELEMENT_TYPE_FIELD_NAME); fields.add(VISIBILITY_FIELD_NAME); fields.addAll(getConfig().getScoringStrategy().getFieldNames()); this.parentDocumentFields = fields.toArray(new String[fields.size()]); } return this.parentDocumentFields; }