From 3b06cd8d92ea30b2375db06701434b7346621eb2 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Tue, 29 Dec 2015 09:17:47 +0100 Subject: [PATCH] Fix pharse suggest collate example to use correct script context/syntax Closes #15675 --- docs/reference/search/suggesters/phrase-suggest.asciidoc | 6 ++++-- .../elasticsearch/messy/tests/SuggestSearchTests.java | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/reference/search/suggesters/phrase-suggest.asciidoc b/docs/reference/search/suggesters/phrase-suggest.asciidoc index bc2f016d288..f88d486fce4 100644 --- a/docs/reference/search/suggesters/phrase-suggest.asciidoc +++ b/docs/reference/search/suggesters/phrase-suggest.asciidoc @@ -192,8 +192,10 @@ curl -XPOST 'localhost:9200/_search' -d { } ], "collate": { "query": { <1> - "match": { - "{{field_name}}" : "{{suggestion}}" <2> + "inline" : { + "match": { + "{{field_name}}" : "{{suggestion}}" <2> + } } }, "params": {"field_name" : "title"}, <3> diff --git a/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/SuggestSearchTests.java b/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/SuggestSearchTests.java index a0699a35534..b0f2f576249 100644 --- a/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/SuggestSearchTests.java +++ b/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/SuggestSearchTests.java @@ -82,12 +82,12 @@ import static org.hamcrest.Matchers.nullValue; * request, modify again, request again, etc. This makes it very obvious what changes between requests. */ public class SuggestSearchTests extends ESIntegTestCase { - + @Override protected Collection> nodePlugins() { return Collections.singleton(MustachePlugin.class); } - + // see #3196 public void testSuggestAcrossMultipleIndices() throws IOException { createIndex("test"); @@ -618,7 +618,7 @@ public class SuggestSearchTests extends ESIntegTestCase { // Check the name this time because we're repeating it which is funky assertThat(searchSuggest.getSuggestion("simple_phrase").getEntries().get(0).getText().string(), equalTo("Xor the Got-Jewel Xor the Got-Jewel Xor the Got-Jewel")); } - + private List readMarvelHeroNames() throws IOException, URISyntaxException { return Files.readAllLines(PathUtils.get(Suggest.class.getResource("/config/names.txt").toURI()), StandardCharsets.UTF_8); } @@ -1166,11 +1166,12 @@ public class SuggestSearchTests extends ESIntegTestCase { String filterString = XContentFactory.jsonBuilder() .startObject() .startObject("match_phrase") - .field("title", "{{suggestion}}") + .field("{{field}}", "{{suggestion}}") .endObject() .endObject() .string(); PhraseSuggestionBuilder filteredQuerySuggest = suggest.collateQuery(filterString); + filteredQuerySuggest.collateParams(Collections.singletonMap("field", "title")); searchSuggest = searchSuggest("united states house of representatives elections in washington 2006", filteredQuerySuggest); assertSuggestionSize(searchSuggest, 0, 2, "title");