Skip to content

Commit

Permalink
Rename template query parameter names.
Browse files Browse the repository at this point in the history
This makes the names of the parameters a template query accepts shorter and
clearer.

Relates to elastic#4879
  • Loading branch information
Isabel Drost-Fromm committed Feb 14, 2014
1 parent 6725fc8 commit e1806a9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 2 additions & 0 deletions docs/reference/query-dsl/queries.asciidoc
Expand Up @@ -81,3 +81,5 @@ include::queries/wildcard-query.asciidoc[]
include::queries/minimum-should-match.asciidoc[]

include::queries/multi-term-rewrite.asciidoc[]

include::queries/template-query.asciidoc[]
Expand Up @@ -18,11 +18,6 @@
*/
package org.elasticsearch.index.query;

import java.io.IOException;

import java.util.HashMap;
import java.util.Map;

import org.apache.lucene.search.Query;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.inject.Inject;
Expand All @@ -31,6 +26,10 @@
import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.ScriptService;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
* In the simplest case, parse template string and variables from the request, compile the template and
* execute the template against the given variables.
Expand All @@ -42,9 +41,9 @@ public class TemplateQueryParser implements QueryParser {
/** Name to reference this type of query. */
public static final String NAME = "template";
/** Name of query parameter containing the template string. */
public static final String STRING = "template_string";
public static final String STRING = "query";
/** Name of query parameter containing the template parameters. */
public static final String VARS = "template_vars";
public static final String VARS = "params";
/** This is what we are registered with for query executions. */
private final ScriptService scriptService;

Expand Down
Expand Up @@ -43,7 +43,7 @@ public void testJSONGeneration() throws IOException {
builder.doXContent(content, null);
content.endObject();
content.close();
assertEquals(content.string(), "{\"template\":{\"template_string\":\"I am a $template string\",\"template_vars\":{\"template\":\"filled\"}}}");
assertEquals(content.string(), "{\"template\":{\"query\":\"I am a $template string\",\"params\":{\"template\":\"filled\"}}}");
}

}
Expand Up @@ -58,8 +58,8 @@ public class TemplateQueryParserTest extends ElasticsearchTestCase {
@Test
public void testParser() throws IOException {
String templateString = "{\"template\": {"
+ "\"template_string\":\"{\\\"match_{{template}}\\\": {}}\","
+ "\"template_vars\":{\"template\":\"all\"}}" + "}";
+ "\"query\":\"{\\\"match_{{template}}\\\": {}}\","
+ "\"params\":{\"template\":\"all\"}}" + "}";

Settings settings = ImmutableSettings.Builder.EMPTY_SETTINGS;

Expand Down

0 comments on commit e1806a9

Please sign in to comment.