@Test public void applyFieldFacet_FieldPrefixNotEmpty() { SolrQuery query = new SolrQuery(); when(fieldValuePrefixAdder.prefixWithSeparator("fieldPrefix")).thenReturn("fieldPrefix#"); fieldFacetToQueryApplier.applyFieldFacet(query, "fieldName", "fieldPrefix"); assertThat(query.getParams("facet"), arrayContaining("true")); assertThat(query.getParams("facet.field"), arrayContaining("fieldName")); assertThat(query.getParams("f.fieldName.facet.prefix"), arrayContaining("fieldPrefix#")); assertThat(query.getParams("f.fieldName.facet.sort"), arrayContaining(FacetParams.FACET_SORT_INDEX)); }
public void applyFieldFacet(SolrQuery query, String fieldName, String fieldValuePrefix) { Preconditions.checkNotNull(query); Preconditions.checkNotNull(fieldName); Preconditions.checkArgument(StringUtils.isNotBlank(fieldName)); String fieldParamPrefix = "f." + fieldName + "."; query.setFacet(true); query.add(fieldParamPrefix + FacetParams.FACET_SORT, FacetParams.FACET_SORT_INDEX); query.add(FacetParams.FACET_FIELD, fieldName); if (!StringUtils.isBlank(fieldValuePrefix)) { query.add(fieldParamPrefix + FacetParams.FACET_PREFIX, fieldValuePrefixAdder.prefixWithSeparator(fieldValuePrefix)); } }
FieldFacetToQueryApplier { public void applyFieldFacet(SolrQuery query, String fieldName, String fieldValuePrefix) { Preconditions.checkNotNull(query); Preconditions.checkNotNull(fieldName); Preconditions.checkArgument(StringUtils.isNotBlank(fieldName)); String fieldParamPrefix = "f." + fieldName + "."; query.setFacet(true); query.add(fieldParamPrefix + FacetParams.FACET_SORT, FacetParams.FACET_SORT_INDEX); query.add(FacetParams.FACET_FIELD, fieldName); if (!StringUtils.isBlank(fieldValuePrefix)) { query.add(fieldParamPrefix + FacetParams.FACET_PREFIX, fieldValuePrefixAdder.prefixWithSeparator(fieldValuePrefix)); } } }
FieldFacetToQueryApplier { public void applyFieldFacet(SolrQuery query, String fieldName, String fieldValuePrefix) { Preconditions.checkNotNull(query); Preconditions.checkNotNull(fieldName); Preconditions.checkArgument(StringUtils.isNotBlank(fieldName)); String fieldParamPrefix = "f." + fieldName + "."; query.setFacet(true); query.add(fieldParamPrefix + FacetParams.FACET_SORT, FacetParams.FACET_SORT_INDEX); query.add(FacetParams.FACET_FIELD, fieldName); if (!StringUtils.isBlank(fieldValuePrefix)) { query.add(fieldParamPrefix + FacetParams.FACET_PREFIX, fieldValuePrefixAdder.prefixWithSeparator(fieldValuePrefix)); } }  }
FieldFacetToQueryApplier { public void applyFieldFacet(SolrQuery query, String fieldName, String fieldValuePrefix) { Preconditions.checkNotNull(query); Preconditions.checkNotNull(fieldName); Preconditions.checkArgument(StringUtils.isNotBlank(fieldName)); String fieldParamPrefix = "f." + fieldName + "."; query.setFacet(true); query.add(fieldParamPrefix + FacetParams.FACET_SORT, FacetParams.FACET_SORT_INDEX); query.add(FacetParams.FACET_FIELD, fieldName); if (!StringUtils.isBlank(fieldValuePrefix)) { query.add(fieldParamPrefix + FacetParams.FACET_PREFIX, fieldValuePrefixAdder.prefixWithSeparator(fieldValuePrefix)); } }  void applyFieldFacet(SolrQuery query, String fieldName, String fieldValuePrefix); @Autowired void setFieldValuePrefixAdder(FieldValuePrefixAdder fieldValuePrefixAdder); }
FieldFacetToQueryApplier { public void applyFieldFacet(SolrQuery query, String fieldName, String fieldValuePrefix) { Preconditions.checkNotNull(query); Preconditions.checkNotNull(fieldName); Preconditions.checkArgument(StringUtils.isNotBlank(fieldName)); String fieldParamPrefix = "f." + fieldName + "."; query.setFacet(true); query.add(fieldParamPrefix + FacetParams.FACET_SORT, FacetParams.FACET_SORT_INDEX); query.add(FacetParams.FACET_FIELD, fieldName); if (!StringUtils.isBlank(fieldValuePrefix)) { query.add(fieldParamPrefix + FacetParams.FACET_PREFIX, fieldValuePrefixAdder.prefixWithSeparator(fieldValuePrefix)); } }  void applyFieldFacet(SolrQuery query, String fieldName, String fieldValuePrefix); @Autowired void setFieldValuePrefixAdder(FieldValuePrefixAdder fieldValuePrefixAdder);  }