@Test @UseDataProvider("transformCriterionWithParsingData") public void transformToEqualsCriterionWithParsing(String expectedQuery, String criterionValue) { String actualQuery = criterionTransformer.transformToEqualsCriterionWithParsing(JudgmentIndexField.CONTENT, criterionValue); assertEquals(expectedQuery, actualQuery); }
public String transformToEqualsCriterionWithParsing(F field, String value) { if (StringUtils.isBlank(value)) { return StringUtils.EMPTY; } List<String> splittedByPhrases = splitByPhrases(value); List<String> splittedByWords = splitByWords(splittedByPhrases); List<List<String>> groupedByOrOperator = groupByOrOperator(splittedByWords); List<String> queryParts = new LinkedList<String>(); for (List<String> orValuesGroup : groupedByOrOperator) { String queryPart = null; if (orValuesGroup.size() == 1) { queryPart = buildParsedEqualsCriterion(field.getFieldName(), orValuesGroup.get(0), "+"); } else { List<String> orQueryParts = Lists.newLinkedList(); for (String orValue : orValuesGroup) { if (isExclusion(orValue)) { orQueryParts.add("(*:* " + buildParsedEqualsCriterion(field.getFieldName(), orValue, "") + ")"); } else { orQueryParts.add(buildParsedEqualsCriterion(field.getFieldName(), orValue, "")); } } queryPart = "+(" + orQueryParts.stream().collect(Collectors.joining(" ")) + ")"; } queryParts.add(queryPart); } return queryParts.stream().collect(Collectors.joining(" ")); }
SolrCriterionTransformer { public String transformToEqualsCriterionWithParsing(F field, String value) { if (StringUtils.isBlank(value)) { return StringUtils.EMPTY; } List<String> splittedByPhrases = splitByPhrases(value); List<String> splittedByWords = splitByWords(splittedByPhrases); List<List<String>> groupedByOrOperator = groupByOrOperator(splittedByWords); List<String> queryParts = new LinkedList<String>(); for (List<String> orValuesGroup : groupedByOrOperator) { String queryPart = null; if (orValuesGroup.size() == 1) { queryPart = buildParsedEqualsCriterion(field.getFieldName(), orValuesGroup.get(0), "+"); } else { List<String> orQueryParts = Lists.newLinkedList(); for (String orValue : orValuesGroup) { if (isExclusion(orValue)) { orQueryParts.add("(*:* " + buildParsedEqualsCriterion(field.getFieldName(), orValue, "") + ")"); } else { orQueryParts.add(buildParsedEqualsCriterion(field.getFieldName(), orValue, "")); } } queryPart = "+(" + orQueryParts.stream().collect(Collectors.joining(" ")) + ")"; } queryParts.add(queryPart); } return queryParts.stream().collect(Collectors.joining(" ")); } }
SolrCriterionTransformer { public String transformToEqualsCriterionWithParsing(F field, String value) { if (StringUtils.isBlank(value)) { return StringUtils.EMPTY; } List<String> splittedByPhrases = splitByPhrases(value); List<String> splittedByWords = splitByWords(splittedByPhrases); List<List<String>> groupedByOrOperator = groupByOrOperator(splittedByWords); List<String> queryParts = new LinkedList<String>(); for (List<String> orValuesGroup : groupedByOrOperator) { String queryPart = null; if (orValuesGroup.size() == 1) { queryPart = buildParsedEqualsCriterion(field.getFieldName(), orValuesGroup.get(0), "+"); } else { List<String> orQueryParts = Lists.newLinkedList(); for (String orValue : orValuesGroup) { if (isExclusion(orValue)) { orQueryParts.add("(*:* " + buildParsedEqualsCriterion(field.getFieldName(), orValue, "") + ")"); } else { orQueryParts.add(buildParsedEqualsCriterion(field.getFieldName(), orValue, "")); } } queryPart = "+(" + orQueryParts.stream().collect(Collectors.joining(" ")) + ")"; } queryParts.add(queryPart); } return queryParts.stream().collect(Collectors.joining(" ")); }  }
SolrCriterionTransformer { public String transformToEqualsCriterionWithParsing(F field, String value) { if (StringUtils.isBlank(value)) { return StringUtils.EMPTY; } List<String> splittedByPhrases = splitByPhrases(value); List<String> splittedByWords = splitByWords(splittedByPhrases); List<List<String>> groupedByOrOperator = groupByOrOperator(splittedByWords); List<String> queryParts = new LinkedList<String>(); for (List<String> orValuesGroup : groupedByOrOperator) { String queryPart = null; if (orValuesGroup.size() == 1) { queryPart = buildParsedEqualsCriterion(field.getFieldName(), orValuesGroup.get(0), "+"); } else { List<String> orQueryParts = Lists.newLinkedList(); for (String orValue : orValuesGroup) { if (isExclusion(orValue)) { orQueryParts.add("(*:* " + buildParsedEqualsCriterion(field.getFieldName(), orValue, "") + ")"); } else { orQueryParts.add(buildParsedEqualsCriterion(field.getFieldName(), orValue, "")); } } queryPart = "+(" + orQueryParts.stream().collect(Collectors.joining(" ")) + ")"; } queryParts.add(queryPart); } return queryParts.stream().collect(Collectors.joining(" ")); }  String transformToEqualsCriterionWithParsing(F field, String value); String transformToEqualsCriterion(F field, String value); String transformToEqualsCriterion(F field, String value, Operator operator); String transformToEqualsCriterion(F field, Integer value); String transformToEqualsCriterion(F field, Long value); String transformToEqualsCriterion(F field, Enum<?> enumValue); String transformToEqualsCriteria(F field, List<String> values, Operator operator); String transformToEqualsEnumCriteria(F field, List<? extends Enum<?>> values, Operator operator); String transformToDateRangeCriterion(F field, LocalDate from, LocalDate to); String transformToRangeCriterion(F field, String from, String to); String and(String criterion); String join(List<String> criteria); }
SolrCriterionTransformer { public String transformToEqualsCriterionWithParsing(F field, String value) { if (StringUtils.isBlank(value)) { return StringUtils.EMPTY; } List<String> splittedByPhrases = splitByPhrases(value); List<String> splittedByWords = splitByWords(splittedByPhrases); List<List<String>> groupedByOrOperator = groupByOrOperator(splittedByWords); List<String> queryParts = new LinkedList<String>(); for (List<String> orValuesGroup : groupedByOrOperator) { String queryPart = null; if (orValuesGroup.size() == 1) { queryPart = buildParsedEqualsCriterion(field.getFieldName(), orValuesGroup.get(0), "+"); } else { List<String> orQueryParts = Lists.newLinkedList(); for (String orValue : orValuesGroup) { if (isExclusion(orValue)) { orQueryParts.add("(*:* " + buildParsedEqualsCriterion(field.getFieldName(), orValue, "") + ")"); } else { orQueryParts.add(buildParsedEqualsCriterion(field.getFieldName(), orValue, "")); } } queryPart = "+(" + orQueryParts.stream().collect(Collectors.joining(" ")) + ")"; } queryParts.add(queryPart); } return queryParts.stream().collect(Collectors.joining(" ")); }  String transformToEqualsCriterionWithParsing(F field, String value); String transformToEqualsCriterion(F field, String value); String transformToEqualsCriterion(F field, String value, Operator operator); String transformToEqualsCriterion(F field, Integer value); String transformToEqualsCriterion(F field, Long value); String transformToEqualsCriterion(F field, Enum<?> enumValue); String transformToEqualsCriteria(F field, List<String> values, Operator operator); String transformToEqualsEnumCriteria(F field, List<? extends Enum<?>> values, Operator operator); String transformToDateRangeCriterion(F field, LocalDate from, LocalDate to); String transformToRangeCriterion(F field, String from, String to); String and(String criterion); String join(List<String> criteria);  }