Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/4879 #5036

Merged
merged 0 commits into from Feb 20, 2014
Merged

Feature/4879 #5036

merged 0 commits into from Feb 20, 2014

Conversation

MaineC
Copy link

@MaineC MaineC commented Feb 6, 2014

PR for #4879

/**
* Test building and serialising a template search request.
* */
public class TemplateQueryBuilderTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should extends ElasticsearchTestCase

@s1monw
Copy link
Contributor

s1monw commented Feb 11, 2014

I think this looks pretty awesome. I left some comments but in general we are very close here. Lets chat about the dependency and how we handle that...

@MaineC
Copy link
Author

MaineC commented Feb 11, 2014

Thanks a lot for your comments - fixing now. Dependency: Sure.

@s1monw
Copy link
Contributor

s1monw commented Feb 11, 2014

thank you!

"{\"match_{{template}}\": {}}\"", vars);
SearchResponse sr = client().prepareSearch().setQuery(builder)
.execute().actionGet();
assertEquals("Template query didn't return correct number of hits.", 2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could also use ElasticsearchAssertions.assertHitCount here

@spinscale
Copy link
Contributor

I like the functionality a lot (just what I need it in one of my playground projects :-)

Two minor things that came to my mind while reading the PR:

  • IIRC the DefaultMustacheFactory uses internally an unbounded guava cache for storing the templates. Does LRU make more sense, exposing stats seems overkill
  • The ScriptService has the possibility to refresh files on the filesystem? Does this still work due to the above cache for the mustache templates?

[[query-dsl-template-query]]
=== Template Query

A query that accepts a query template and a map of key/value pairs to fill in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add a coming[1.1.0] here?

@kimchy
Copy link
Member

kimchy commented Feb 15, 2014

Few notes:

  • Agreed on mustache being optional dependency, I don't think we should shade it at all. We need to make sure in our packaging (zip, tar.gz, deb, rpm) it is included as part of the lib dir.
  • I would love to get to a state where the result of running the script is UTF8 bytes (see for example using a thread local UTF8StreamWriter, we do it in StreamOutput). That way we don't need to convert to a string, and then parse the json from a string.

((Mustache) template).execute(writer, vars);
try {
writer.flush();
writer.close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nitpick - can we move the writer.close() into a finally?

@s1monw
Copy link
Contributor

s1monw commented Feb 18, 2014

this looks great to me we only need to speak about the including of Guava in the package... lets talk soon

- do:
indices.refresh: {}

- do:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool stuff maybe we can add a test that use another query than match_all and two documents to add a bit more variance?

@s1monw
Copy link
Contributor

s1monw commented Feb 20, 2014

I did another review, ran the tests and did a release build to make sure it all works and starts up etc. This looks awesome. I left one more comment (minor) but once that is fixed I am +1 to push

@MaineC
Copy link
Author

MaineC commented Feb 20, 2014

Above commit changes the yaml test from using match_all to using a term query.

@s1monw
Copy link
Contributor

s1monw commented Feb 20, 2014

awesome! Isabel please squash the commits into one and feel free to push to 1.x and master!

@MaineC MaineC merged commit 48004ff into elastic:master Feb 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants