feat(Converter): 支持动态字段映射与解析

- 在 MilvusConverter 中添加对动态字段的处理逻辑(目的为了query()无outputFields能获取到$meta)
- 在 SearchRespConverter 中增加对 $meta 字段的解析
This commit is contained in:
苑勇 2025-09-28 21:23:26 +08:00
parent b4dac2083b
commit fd9be066f9
2 changed files with 10 additions and 1 deletions

View File

@ -94,6 +94,9 @@ public class MilvusConverter {
for (Field field : fields) {
MilvusField fieldAnnotation = field.getAnnotation(MilvusField.class);
if (Objects.isNull(fieldAnnotation)) {
if (collectionAnnotation.enableDynamicField()) {
propertyCache.functionToPropertyMap.put("$meta", "$meta");
}
continue;
}
// 处理字段名优先使用注解中的字段名若无则用反射获取的字段名

View File

@ -41,7 +41,13 @@ public class SearchRespConverter {
Map<String, Object> entityMap = new HashMap<>();
for (Map.Entry<String, Object> entry : searchResult.getEntity().entrySet()) {
String key = propertyCache.findKeyByValue(entry.getKey());
if(key!=null){
if (conversionCache.getMilvusEntity().getEnableDynamicField()
&& "$meta".equals(entry.getKey())) {
if (entry.getValue() == null) {
continue;
}
entityMap.putAll(GsonUtil.fromJsonToMap(entry.getValue().toString()));
} else if(key!=null){
Object value = entry.getValue();
entityMap.put(key,value);
}