|
|
@ -178,7 +178,7 @@ public class WeaviateService { |
|
|
|
if(Func.isEmpty(ids) && Func.isNotEmpty(className)) { |
|
|
|
if(Func.isEmpty(ids) && Func.isNotEmpty(className)) { |
|
|
|
// 删除className
|
|
|
|
// 删除className
|
|
|
|
Map<String,String> deleteTableParams = new HashMap<>(1); |
|
|
|
Map<String,String> deleteTableParams = new HashMap<>(1); |
|
|
|
deleteTableParams.put("table_name",className); |
|
|
|
deleteTableParams.put("table_name",className.replace("Hzn_lm_","")); |
|
|
|
RequestClientUtil.postCall(gglmUrl + invokeApi.getDeleteTable(),deleteTableParams); |
|
|
|
RequestClientUtil.postCall(gglmUrl + invokeApi.getDeleteTable(),deleteTableParams); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// 删除记录
|
|
|
|
// 删除记录
|
|
|
@ -333,32 +333,25 @@ public class WeaviateService { |
|
|
|
fields.add(additionalId); |
|
|
|
fields.add(additionalId); |
|
|
|
get.withFields(fields.toArray(new Field[fields.size()])); |
|
|
|
get.withFields(fields.toArray(new Field[fields.size()])); |
|
|
|
if(Func.isNotEmpty(query)) { |
|
|
|
if(Func.isNotEmpty(query)) { |
|
|
|
|
|
|
|
// waeviate 多个filter查询结果
|
|
|
|
List<WhereFilter> whereFilters = query.entrySet().stream().map(e -> WhereFilter.builder() |
|
|
|
List<WhereFilter> whereFilters = query.entrySet().stream().map(e -> WhereFilter.builder() |
|
|
|
.path(e.getKey()) |
|
|
|
.path(e.getKey()) |
|
|
|
.operator(Operator.Equal) |
|
|
|
.operator(Operator.Equal) |
|
|
|
.valueString(e.getValue()) |
|
|
|
.valueString(e.getValue()) |
|
|
|
.build()).collect(Collectors.toList()); |
|
|
|
.build()).collect(Collectors.toList()); |
|
|
|
whereFilters.forEach(where -> get.withWhere(where)); |
|
|
|
WhereFilter combinedFilter = WhereFilter.builder() |
|
|
|
|
|
|
|
.operator(Operator.And) |
|
|
|
|
|
|
|
.operands(whereFilters.toArray(new WhereFilter[whereFilters.size()])) |
|
|
|
|
|
|
|
.build(); |
|
|
|
|
|
|
|
get.withWhere(combinedFilter); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 执行查询并返回结果
|
|
|
|
|
|
|
|
return get.run().getResult().getData(); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
// 异常处理
|
|
|
|
|
|
|
|
System.err.println("Error occurred during query execution: " + e.getMessage()); |
|
|
|
|
|
|
|
throw new RuntimeException("Query failed.", e); |
|
|
|
} |
|
|
|
} |
|
|
|
return get.run().getResult().getData(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// public static void main(String[] args) throws AuthException {
|
|
|
|
|
|
|
|
// Config config = new Config("http", "192.168.60.16:9992");
|
|
|
|
|
|
|
|
// WeaviateClient client = WeaviateAuthClient.apiKey(config, "123");
|
|
|
|
|
|
|
|
// Field itemName = Field.builder().name("item_name").build();
|
|
|
|
|
|
|
|
// Field itemId = Field.builder().name("item_id").build();
|
|
|
|
|
|
|
|
// Field additionalId = Field.builder().name("_additional { id }").build();
|
|
|
|
|
|
|
|
// WhereFilter where = WhereFilter.builder()
|
|
|
|
|
|
|
|
// .path(new String[]{ "item_name" })
|
|
|
|
|
|
|
|
// .operator(Operator.Equal)
|
|
|
|
|
|
|
|
// .valueString("湖北宜昌泵站")
|
|
|
|
|
|
|
|
// .build();
|
|
|
|
|
|
|
|
// Result<GraphQLResponse> result = client.graphQL().get()
|
|
|
|
|
|
|
|
// .withClassName("Hzn_lm_form_station")
|
|
|
|
|
|
|
|
// .withFields(itemName,itemId,additionalId)
|
|
|
|
|
|
|
|
// .withWhere(where)
|
|
|
|
|
|
|
|
// .run();
|
|
|
|
|
|
|
|
// System.out.println(JSON.toJSONString(result.getResult().getData()));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|