spring-ai
spring-ai copied to clipboard
Customizable text/content property in Neo4jVectorStore
In the Neo4jVectorStore.java, please enable the builder to update the context property name. Currently:
private Document recordToDocument(Record neoRecord) {
Node node = neoRecord.get("node").asNode();
float score = neoRecord.get("score").asFloat();
HashMap<String, Object> metaData = new HashMap();
metaData.put(DocumentMetadata.DISTANCE.value(), 1.0F - score);
node.keys().forEach((key) -> {
if (key.startsWith("metadata.")) {
metaData.put(key.substring(key.indexOf(".") + 1), node.get(key).asObject());
}
});
return Document.builder().id(node.get(this.idProperty).asString()).text(node.get("text").asString()).metadata(Map.copyOf(metaData)).score((double)score).build();
}
Desired:
private Document recordToDocument(Record neoRecord) {
Node node = neoRecord.get("node").asNode();
float score = neoRecord.get("score").asFloat();
HashMap<String, Object> metaData = new HashMap();
metaData.put(DocumentMetadata.DISTANCE.value(), 1.0F - score);
node.keys().forEach((key) -> {
if (key.startsWith("metadata.")) {
metaData.put(key.substring(key.indexOf(".") + 1), node.get(key).asObject());
}
});
return Document.builder().id(node.get(this.idProperty).asString()).text(node.get(this.contentProperty).asString()).metadata(Map.copyOf(metaData)).score((double)score).build();
}
TL:DR pls add contentProperty to define custom property name, same implementation as idProperty.
Expected Behavior
Neo4jVectorStoreBuilder to have .contentProperty(String contentProperty) just like .idProperty(String idProperty)
Current Behavior
no way of easily configuring custom text property field to use when building retrieved Document
Context
We have an existing Neo4j vector store and updating all our services is not an option. currently we have to create custom advisors for these basic QuestionAnswer advisor simply because we cant configure the text property.