|
@@ -0,0 +1,74 @@
|
|
|
+package cn.cslg.pas.factorys.EsBuilderFactory;
|
|
|
+
|
|
|
+import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
|
|
+import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class PrioritiesNONestedQueryBuilder implements IQueryBuilder{
|
|
|
+ private String field = "";
|
|
|
+ private String value = "";
|
|
|
+ private String operator = "";
|
|
|
+ public String path = "";
|
|
|
+ public Integer projectId = null;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Query creteQuery() throws ParseException {
|
|
|
+ List<Query> queries = new ArrayList<>();
|
|
|
+ String[] valueStrs = value.split("[,,]|\\r\\n|\\r|\\n");
|
|
|
+ for (int i = 0; i < valueStrs.length; i++) {
|
|
|
+ String temValue = valueStrs[i];
|
|
|
+ String str = "*";
|
|
|
+ String s = str.concat(temValue).concat("*");
|
|
|
+ Query query = QueryBuilders.wildcard(n -> n.field(field).value(s));
|
|
|
+ Query nestedQuery = QueryBuilders.nested(z -> z.path(path).query(query));
|
|
|
+ queries.add(nestedQuery);
|
|
|
+ }
|
|
|
+ return QueryBuilders.bool(m -> m.should(queries));
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getField() {
|
|
|
+ return field;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setField(String field) {
|
|
|
+ this.field = field;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getValue() {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setValue(String value) {
|
|
|
+ this.value = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getOperator() {
|
|
|
+ return operator;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setOperator(String operator) {
|
|
|
+ this.operator = operator;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getPath() {
|
|
|
+ return path;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setPath(String path) {
|
|
|
+ this.path = path;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer getProjectId() {
|
|
|
+ return projectId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setProjectId(Integer projectId) {
|
|
|
+ this.projectId = projectId;
|
|
|
+ }
|
|
|
+}
|