Search in sources :

Example 1 with ElementType

use of org.vertexium.ElementType in project vertexium by visallo.

the class IdStrategy method extendedDataRowIdFromSearchHit.

public ExtendedDataRowId extendedDataRowIdFromSearchHit(SearchHit hit) {
    SearchHitField elementTypeField = hit.getFields().get(Elasticsearch5SearchIndex.ELEMENT_TYPE_FIELD_NAME);
    if (elementTypeField == null) {
        throw new VertexiumException("Could not find field: " + Elasticsearch5SearchIndex.ELEMENT_TYPE_FIELD_NAME);
    }
    ElementType elementType = ElasticsearchDocumentType.parse(elementTypeField.getValue().toString()).toElementType();
    SearchHitField elementIdField = hit.getFields().get(Elasticsearch5SearchIndex.ELEMENT_ID_FIELD_NAME);
    if (elementIdField == null) {
        throw new VertexiumException("Could not find field: " + Elasticsearch5SearchIndex.ELEMENT_ID_FIELD_NAME);
    }
    String elementId = elementIdField.getValue();
    SearchHitField tableNameField = hit.getFields().get(Elasticsearch5SearchIndex.EXTENDED_DATA_TABLE_NAME_FIELD_NAME);
    if (tableNameField == null) {
        throw new VertexiumException("Could not find field: " + Elasticsearch5SearchIndex.EXTENDED_DATA_TABLE_NAME_FIELD_NAME);
    }
    String tableName = tableNameField.getValue();
    SearchHitField rowIdField = hit.getFields().get(Elasticsearch5SearchIndex.EXTENDED_DATA_TABLE_ROW_ID_FIELD_NAME);
    if (rowIdField == null) {
        throw new VertexiumException("Could not find field: " + Elasticsearch5SearchIndex.EXTENDED_DATA_TABLE_ROW_ID_FIELD_NAME);
    }
    String rowId = rowIdField.getValue();
    return new ExtendedDataRowId(elementType, elementId, tableName, rowId);
}
Also used : ElementType(org.vertexium.ElementType) ExtendedDataRowId(org.vertexium.ExtendedDataRowId) SearchHitField(org.elasticsearch.search.SearchHitField) VertexiumException(org.vertexium.VertexiumException)

Aggregations

SearchHitField (org.elasticsearch.search.SearchHitField)1 ElementType (org.vertexium.ElementType)1 ExtendedDataRowId (org.vertexium.ExtendedDataRowId)1 VertexiumException (org.vertexium.VertexiumException)1