diff --git a/src/main/java/dk/kb/netarchivesuite/solrwayback/util/SolrUtils.java b/src/main/java/dk/kb/netarchivesuite/solrwayback/util/SolrUtils.java index 6b253cfe..f8a357a2 100644 --- a/src/main/java/dk/kb/netarchivesuite/solrwayback/util/SolrUtils.java +++ b/src/main/java/dk/kb/netarchivesuite/solrwayback/util/SolrUtils.java @@ -430,8 +430,8 @@ public static String fieldValueToString(Object value) { */ public static String combineFilterQueries(String predefinedFilterField, String predefinedFilterValue, String[] filterQueries) { Stream filtersStream = Stream.of(filterQueries); - Stream fullFiltersStream =Stream.concat(Stream.of(predefinedFilterField + ":(" + predefinedFilterValue + ")"), filtersStream); + Stream fullFiltersStream =Stream.concat(Stream.of(predefinedFilterField + ":" + predefinedFilterValue), filtersStream); return fullFiltersStream - .collect(Collectors.joining(" AND ", "(", ")")); + .collect(Collectors.joining(") AND (", "(", ")")); } } diff --git a/src/test/java/dk/kb/netarchivesuite/solrwayback/util/SolrUtilsTest.java b/src/test/java/dk/kb/netarchivesuite/solrwayback/util/SolrUtilsTest.java index ddc16f82..3c7e41ac 100644 --- a/src/test/java/dk/kb/netarchivesuite/solrwayback/util/SolrUtilsTest.java +++ b/src/test/java/dk/kb/netarchivesuite/solrwayback/util/SolrUtilsTest.java @@ -2,13 +2,15 @@ import org.junit.Test; +import static org.junit.Assert.assertEquals; + public class SolrUtilsTest { @Test public void combineFilterQueriesTest(){ - String[] filtersFromFrontend = new String[]{"filter1:value1", "filter2:value2"}; + String[] filtersFromFrontend = new String[]{"filter1:value1", "filter2:value2", "foo:bar OR bar:zoo"}; String filterquery = SolrUtils.combineFilterQueries("content_type", "text/html", filtersFromFrontend); - System.out.println(filterquery); + assertEquals("(content_type:text/html) AND (filter1:value1) AND (filter2:value2) AND (foo:bar OR bar:zoo)", filterquery); } }