mirror of
https://gitee.com/dromara/MilvusPlus.git
synced 2025-12-07 17:38:24 +08:00
feat(Converter): 支持动态字段映射与解析
- 在 MilvusConverter 中添加对动态字段的处理逻辑(目的为了query()无outputFields能获取到$meta) - 在 SearchRespConverter 中增加对 $meta 字段的解析
This commit is contained in:
parent
b4dac2083b
commit
fd9be066f9
@ -94,6 +94,9 @@ public class MilvusConverter {
|
|||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
MilvusField fieldAnnotation = field.getAnnotation(MilvusField.class);
|
MilvusField fieldAnnotation = field.getAnnotation(MilvusField.class);
|
||||||
if (Objects.isNull(fieldAnnotation)) {
|
if (Objects.isNull(fieldAnnotation)) {
|
||||||
|
if (collectionAnnotation.enableDynamicField()) {
|
||||||
|
propertyCache.functionToPropertyMap.put("$meta", "$meta");
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 处理字段名,优先使用注解中的字段名,若无则用反射获取的字段名
|
// 处理字段名,优先使用注解中的字段名,若无则用反射获取的字段名
|
||||||
|
|||||||
@ -41,7 +41,13 @@ public class SearchRespConverter {
|
|||||||
Map<String, Object> entityMap = new HashMap<>();
|
Map<String, Object> entityMap = new HashMap<>();
|
||||||
for (Map.Entry<String, Object> entry : searchResult.getEntity().entrySet()) {
|
for (Map.Entry<String, Object> entry : searchResult.getEntity().entrySet()) {
|
||||||
String key = propertyCache.findKeyByValue(entry.getKey());
|
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();
|
Object value = entry.getValue();
|
||||||
entityMap.put(key,value);
|
entityMap.put(key,value);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user