Commit cae91623 authored by Michael Becker's avatar Michael Becker
Browse files

allow multiple fields in flexible search

parent e81391d8
Pipeline #12079 passed with stage
in 3 minutes and 30 seconds
......@@ -213,7 +213,7 @@ public class SearchFormBuilderServlet extends MCRServlet {
}
case DateRange: {
final String calType = parameters.get("caltype-" + id)[0];
final String[] fields = StringUtils.split(field, ";");
final String[] fields = StringUtils.split(field, ",");
final String fromDateField = fields[0];
final String toDateField = fields[1];
......@@ -304,19 +304,15 @@ public class SearchFormBuilderServlet extends MCRServlet {
}
final String[] values = StringUtils.split(prop, ':');
final String field = StringUtils.replace(values[1], ";", ",");
final String type = values[0];
final String displayName;
final String field;
final String type;
final String classificationId;
if (3 == values.length) {
type = values[0];
field = values[1];
displayName = values[2];
classificationId = null;
} else if (4 == values.length) {
type = values[0];
field = values[1];
classificationId = values[2];
displayName = values[3];
} else {
......
......@@ -40,9 +40,13 @@ public class SearchFormBuilderServletTest extends MyMssSolrTest {
MCRConfiguration2.set("MCR.SearchFormBuilder.Fields.agent",
"daterange:agent_firstdate_from;agent_firstdate_to:module.dptbase.agent.firstDate.labels");
MCRConfiguration2.set("MCR.SearchFormBuilder.Fields.manuscript",
"%MCR.SearchFormBuilder.Fields.manuscript%," +
"text:mymss_mssTitle_general_orig;mymss_mssTitle_general_diacr;mymss_mssTitle_ar;" +
"mymss_mssTitle_de;mymss_mssTitle_en;mymss_mssTitle_id:module.mymss.manuscript.mss39.labels");
result = servlet.buildFieldList("manuscript");
assertThat(result.size(), is(3));
assertThat(result.size(), is(4));
assertThat(result.get(0).getField(), is("category"));
assertThat(result.get(0).getType(), is("classification"));
assertThat(result.get(0).getClassificationId(), is("MyMssAlphabet"));
......@@ -56,9 +60,15 @@ public class SearchFormBuilderServletTest extends MyMssSolrTest {
assertThat(result.get(2).getType(), is("bool"));
assertThat(result.get(2).getDisplayName(), is("???module.mymss.manuscript.mss63.search???"));
assertThat(result.get(3).getField(), is(
"mymss_mssTitle_general_orig,mymss_mssTitle_general_diacr," +
"mymss_mssTitle_ar,mymss_mssTitle_de,mymss_mssTitle_en,mymss_mssTitle_id"));
assertThat(result.get(3).getType(), is("text"));
assertThat(result.get(3).getDisplayName(), is("???module.mymss.manuscript.mss39.labels???"));
result = servlet.buildFieldList("agent");
assertThat(result.size(), is(1));
assertThat(result.get(0).getField(), is("agent_firstdate_from;agent_firstdate_to"));
assertThat(result.get(0).getField(), is("agent_firstdate_from,agent_firstdate_to"));
assertThat(result.get(0).getType(), is("daterange"));
assertThat(result.get(0).getDisplayName(), is("???module.dptbase.agent.firstDate.labels???"));
}
......@@ -152,7 +162,7 @@ public class SearchFormBuilderServletTest extends MyMssSolrTest {
input.putAll(Map.of(
"type-firstdate", new String[]{"daterange"},
"operator-firstdate", new String[]{"between"},
"field-firstdate", new String[]{"agent_firstdate_from;agent_firstdate_to"},
"field-firstdate", new String[]{"agent_firstdate_from,agent_firstdate_to"},
"value-firstdate", new String[]{"1500", "1600"},
"caltype-firstdate", new String[]{"gregorian"}
));
......@@ -173,7 +183,7 @@ public class SearchFormBuilderServletTest extends MyMssSolrTest {
input = new HashMap<>(Map.of(
"type-firstdate2", new String[]{"daterange"},
"operator-firstdate2", new String[]{"between"},
"field-firstdate2", new String[]{"agent_firstdate_from;agent_firstdate_to"},
"field-firstdate2", new String[]{"agent_firstdate_from,agent_firstdate_to"},
"value-firstdate2", new String[]{"1500", null},
"caltype-firstdate2", new String[]{"gregorian"}
));
......@@ -185,7 +195,7 @@ public class SearchFormBuilderServletTest extends MyMssSolrTest {
input = new HashMap<>(Map.of(
"type-firstdate3", new String[]{"daterange"},
"operator-firstdate3", new String[]{"between"},
"field-firstdate3", new String[]{"agent_firstdate_from;agent_firstdate_to"},
"field-firstdate3", new String[]{"agent_firstdate_from,agent_firstdate_to"},
"value-firstdate3", new String[]{null, "1600"},
"caltype-firstdate3", new String[]{"gregorian"}
));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment