Skip to content
Snippets Groups Projects
Commit 53dfb04a authored by Thorsten Vitt's avatar Thorsten Vitt
Browse files

ZIP: Added 'filter' argument to search export

parent 990dc262
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/webapp/WEB-INF"> <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/webapp/WEB-INF">
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<saxon-version>9.5.1-5</saxon-version> <!-- XXX mind dependency from epubcheck --> <saxon-version>9.5.1-5</saxon-version> <!-- XXX mind dependency from epubcheck -->
<cxf-version>2.7.11</cxf-version> <cxf-version>2.7.11</cxf-version>
<confclient-version>1.4.0</confclient-version> <confclient-version>1.4.0</confclient-version>
<tgsearch-version>3.0.2-SNAPSHOT</tgsearch-version> <tgsearch-version>3.4.0-SNAPSHOT</tgsearch-version>
<tgcrud-version>2.6.0</tgcrud-version> <tgcrud-version>2.6.0</tgcrud-version>
<guava-version>15.0</guava-version> <guava-version>15.0</guava-version>
<junit-version>4.11</junit-version> <junit-version>4.11</junit-version>
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
...@@ -170,8 +171,8 @@ private static URI[] extractURIs(final String uriList) { ...@@ -170,8 +171,8 @@ private static URI[] extractURIs(final String uriList) {
return uris; return uris;
} }
protected void initFromSearch(final String query, final String target, int start, int stop) { protected void initFromSearch(final String query, final String target, int start, int stop, List<String> filter) {
rootObjects = SearchResultList.create(repository.getPublicSearchClient(), query, target).start(start).stop(stop); rootObjects = SearchResultList.create(repository.getPublicSearchClient(), query, target, filter).start(start).stop(stop);
} }
/** /**
......
...@@ -174,6 +174,7 @@ public Response getZIP( ...@@ -174,6 +174,7 @@ public Response getZIP(
@QueryParam("transform") @Description("(EXPERIMENTAL) Transform each XML document before zipping. Values currently available are text, html, or the textgrid: URI of an XSLT stylesheet.") final String transform, @QueryParam("transform") @Description("(EXPERIMENTAL) Transform each XML document before zipping. Values currently available are text, html, or the textgrid: URI of an XSLT stylesheet.") final String transform,
@QueryParam("query") @Description("(EXPERIMENTAL) perform the given TGsearch query and use its result as root objects instead of the objects.") final String query, @QueryParam("query") @Description("(EXPERIMENTAL) perform the given TGsearch query and use its result as root objects instead of the objects.") final String query,
@QueryParam("filter") @Description("for query: additional filters") final List<String> filter,
@QueryParam("target") @Description("if query is used, the query target (metadata, fulltext or both)") @DefaultValue("both") final String target, @QueryParam("target") @Description("if query is used, the query target (metadata, fulltext or both)") @DefaultValue("both") final String target,
@QueryParam("start") @Description("for query: start at result no.") @DefaultValue("0") int start, @QueryParam("start") @Description("for query: start at result no.") @DefaultValue("0") int start,
@QueryParam("stop") @Description("for query: max. number of results") @DefaultValue("65535") int stop, @QueryParam("stop") @Description("for query: max. number of results") @DefaultValue("65535") int stop,
...@@ -190,7 +191,7 @@ public Response getZIP( ...@@ -190,7 +191,7 @@ public Response getZIP(
if (sid != null) if (sid != null)
zipResult.sid(sid); zipResult.sid(sid);
if (query != null) if (query != null)
zipResult.initFromSearch(query, target, start, stop); zipResult.initFromSearch(query, target, start, stop, filter);
if (stream) if (stream)
zipResult.streaming(stream); zipResult.streaming(stream);
return zipResult.createResponse().build(); return zipResult.createResponse().build();
......
...@@ -60,14 +60,14 @@ public boolean hasNext() { ...@@ -60,14 +60,14 @@ public boolean hasNext() {
private int stop = Integer.MAX_VALUE; private int stop = Integer.MAX_VALUE;
private SearchClient searchClient; private SearchClient searchClient;
protected SearchResultList(final SearchClient client, final String query, final String target) { protected SearchResultList(final SearchClient client, final String query, final String target, List<String> filter) {
this.searchClient = client; this.searchClient = client;
this.query = query; this.query = query;
client.setTarget(target); client.setTarget(target);
} }
public static SearchResultList create(final SearchClient client, final String query, final String target) { public static SearchResultList create(final SearchClient client, final String query, final String target, List<String> filter) {
return new SearchResultList(client, query, target); return new SearchResultList(client, query, target, filter);
} }
private void ensureNotStarted() { private void ensureNotStarted() {
...@@ -104,6 +104,8 @@ public int size() { ...@@ -104,6 +104,8 @@ public int size() {
private String query; private String query;
private List<String> filter;
@Override @Override
public Iterator<ObjectType> iterator() { public Iterator<ObjectType> iterator() {
...@@ -138,7 +140,7 @@ protected void fetchNextChunk() { ...@@ -138,7 +140,7 @@ protected void fetchNextChunk() {
return; return;
Response response = searchClient.query(query, null, "", nextStart, Response response = searchClient.query(query, null, "", nextStart,
Math.min(stop - nextStart, chunkSize)); Math.min(stop - nextStart, chunkSize), filter);
hits = Integer.parseInt(response.getHits()); hits = Integer.parseInt(response.getHits());
if (!started) { if (!started) {
availableResults = Lists.newArrayListWithExpectedSize(hits); availableResults = Lists.newArrayListWithExpectedSize(hits);
......
...@@ -15,7 +15,7 @@ public class SearchResultListTest { ...@@ -15,7 +15,7 @@ public class SearchResultListTest {
@Test @Test
public void test() { public void test() {
SearchResultList results = SearchResultList SearchResultList results = SearchResultList
.create(repository.getPublicSearchClient(), "genre:\"verse\" AND edition.agent.value:\"anakreon\"", "both") .create(repository.getPublicSearchClient(), "genre:\"verse\" AND edition.agent.value:\"anakreon\"", "both", null)
.chunkSize(10); .chunkSize(10);
int i = 0; int i = 0;
for (ObjectType object : results) { for (ObjectType object : results) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment