Skip to content

Commit

Permalink
Final cleanup work.
Browse files Browse the repository at this point in the history
Relates to elastic#4879

This moves mustache back to being shaded - having guava (which is a needed
dependency of mustache) explicitly in the distribution files isn't an option:
Used by too many projects and thus likely to cause version conflicts downstream.

In addition this adds a rest test for the query templating feature.
  • Loading branch information
Isabel Drost-Fromm committed Feb 19, 2014
1 parent be48f5f commit 3412f46
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@
<include>org.joda:joda-convert</include>
<include>io.netty:netty</include>
<include>com.ning:compress-lzf</include>
<include>com.github.spullara.mustache.java:compiler</include>
</includes>
</artifactSet>
<relocations>
Expand Down
24 changes: 24 additions & 0 deletions rest-api-spec/test/search/30_template_query_execution.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
"Template query":

- do:
index:
index: test
type: testtype
id: 1
body: { "text": "value1" }
- do:
indices.refresh: {}

- do:
search:
body: { "query": { "template": { "query": "{\"match_{{template}}\": {}}", "params" : { "template" : "all" } } } }

- match: { hits.total: 1 }


- do:
search:
body: { "query": { "template": { "query": {"match_{{template}}": {}}, "params" : { "template" : "all" } } } }

- match: { hits.total: 1 }
2 changes: 0 additions & 2 deletions src/main/assemblies/common-bin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<include>net.java.dev.jna:jna</include>
<include>com.spatial4j:spatial4j</include>
<include>com.vividsolutions:jts</include>
<include>com.github.spullara.mustache.java:compiler</include>
<include>com.google.guava:guava</include>
</includes>
</dependencySet>
<dependencySet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,14 @@ public Object execute(Object template, Map<String, Object> vars) {
((Mustache) template).execute(writer, vars);
try {
writer.flush();
writer.close();
} catch (IOException e) {
logger.error("Could not execute query template: ", e);
logger.error("Could not execute query template (failed to flush writer): ", e);
} finally {
try {
writer.close();
} catch (IOException e) {
logger.error("Could not execute query template (failed to close writer): ", e);
}
}
return result.bytes();
}
Expand Down Expand Up @@ -169,9 +174,14 @@ public Object run() {
((Mustache) mustache).execute(writer, vars);
try {
writer.flush();
writer.close();
} catch (IOException e) {
logger.error("Could not execute query template: ", e);
logger.error("Could not execute query template (failed to flush writer): ", e);
} finally {
try {
writer.close();
} catch (IOException e) {
logger.error("Could not execute query template (failed to close writer): ", e);
}
}
return result.bytes();
}
Expand Down

0 comments on commit 3412f46

Please sign in to comment.