public static <E extends Element> Iterator<Property> search(final AbstractTinkerGraph graph, final String regex,
                                                                final Optional<Class<E>> type) {

        final Supplier<Iterator<Element>> vertices = () -> IteratorUtils.cast(graph.vertices());
        final Supplier<Iterator<Element>> edges = () -> IteratorUtils.cast(graph.edges());
        final Supplier<Iterator<Element>> vertexProperties =
                () -> IteratorUtils.flatMap(vertices.get(), v -> IteratorUtils.cast(v.properties()));

        Iterator it;
        if (!type.isPresent()) {
            it = IteratorUtils.concat(vertices.get(), edges.get(), vertexProperties.get());
        } else switch (type.get().getSimpleName()) {
            case "Edge":
                it = edges.get();
                break;
            case "Vertex":
                it = vertices.get();
                break;
            case "VertexProperty":
                it = vertexProperties.get();
                break;
            default:
                it = IteratorUtils.concat(vertices.get(), edges.get(), vertexProperties.get());
        }

        final Pattern pattern = Pattern.compile(regex);

        // get properties
        it = IteratorUtils.<Element, Property>flatMap(it, e -> IteratorUtils.cast(e.properties()));
        // filter by regex
        it = IteratorUtils.<Property>filter(it, p -> pattern.matcher(p.value().toString()).matches());

        return it;
    }
Search for {@link Property}s attached to {@link Element}s of the supplied element type using the supplied
regex. This is a basic scan+filter operation, not a full text search against an index.
tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerHelper.java