|
|
|
@ -92,7 +92,10 @@ public class WeaviateService {
|
|
|
|
|
// log.info("vector:{}",JSON.toJSONString(vector.get(i)));
|
|
|
|
|
Map<String, Object> properties = this.objectToMap(entities.get(i)); |
|
|
|
|
log.info("properties:{}",JSON.toJSONString(properties)); |
|
|
|
|
creator.withProperties(properties).withVectors(vector.get(i)).run(); |
|
|
|
|
Result<WeaviateObject> run = creator.withProperties(properties).withVectors(vector.get(i)).run(); |
|
|
|
|
if(run.hasErrors()) { |
|
|
|
|
log.error("保存失败!,保存结果为:{}",JSON.toJSONString(run)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
entities.forEach(entity -> creator.withProperties(this.objectToMap(entity)).run()); |
|
|
|
@ -104,7 +107,13 @@ public class WeaviateService {
|
|
|
|
|
private Map<String,Object> objectToMap(Object object) { |
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(object)); |
|
|
|
|
Map<String,Object> properties = new HashMap<>(); |
|
|
|
|
jsonObject.forEach((k,v) -> properties.put(k,v)); |
|
|
|
|
jsonObject.forEach((k,v) -> { |
|
|
|
|
if("id".equalsIgnoreCase(k)) { |
|
|
|
|
properties.put("id_",v); |
|
|
|
|
} else { |
|
|
|
|
properties.put(k,v); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return properties; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|