我如何转换这种查询。
{
"query": {
"nested": {
"path": "consultations",
"query": {
"bool": {
"must": [
{
"match": {
"consultations.prescriptions": "alfuorism"
}
},
{
"match": {
"consultations.Diagnosis": "Fever"
}
}
]
}
}
}
}
}
使用 QueryBuilders 进行 Java 客户端查询
以下 Java 代码将生成您的查询
public NestedQueryBuilder nestedBoolQuery(final Map<String, String> propertyValues, final String nestedPath) {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
Iterator<String> iterator = propertyValues.keySet().iterator();
while (iterator.hasNext()) {
String propertyName = iterator.next();
String propertValue = propertyValues.get(propertyName);
MatchQueryBuilder matchQuery = QueryBuilders.matchQuery(propertyName, propertValue);
boolQueryBuilder.must(matchQuery);
}
return QueryBuilders.nestedQuery(nestedPath, boolQueryBuilder);
}
参数propertyValues
is:
Map<String, String> propertyValues = new HashMap<String, String>();
propertyValues.put("consultations.prescriptions", "alfuorism");
propertyValues.put("consultations.Diagnosis", "Fever");
参数nestedPath
is:
consultations
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)