Bug description The MariaDBVectorStore does not return the score when doing a similarity search. Instead it adds the distance to the metadata of the document.

Environment Spring AI 1.0.0

Steps to reproduce 1. Embed documents and save them in the MariaDBVectorStore 2. Do a similarity search

Expected behavior Get the score via the getter of the document.

Actual behaviour The score is null and the distance is in the metadata.

Minimal Complete Reproducible example I did not create an example application, but here is the mapper method for the MaraDBVectorStore.

Override
public Document mapRow(ResultSet rs, int rowNum) throws SQLException {
    String id = rs.getString(1);
    String content = rs.getString(2);
    Map<String, Object> metadata = toMap(rs.getString(3));
    float distance = rs.getFloat(4);

    metadata.put("distance", distance);

    return new Document(id, content, metadata);
}

In comparison, the PgVectorStore, which also uses the JdbcTemplate with a custom DocumentRowMapper does this differently:

@Override
public Document mapRow(ResultSet rs, int rowNum) throws SQLException {
    String id = rs.getString(COLUMN_ID);
    String content = rs.getString(COLUMN_CONTENT);
    PGobject pgMetadata = rs.getObject(COLUMN_METADATA, PGobject.class);
    Float distance = rs.getFloat(COLUMN_DISTANCE);

    Map<String, Object> metadata = toMap(pgMetadata);
    metadata.put(DocumentMetadata.DISTANCE.value(), distance);

    // @formatter:off
    return Document.builder()
        .id(id)
        .text(content)
        .metadata(metadata)
        .score(1.0 - distance)
        .build(); // @formatter:on
}