|
@@ -19,6 +19,7 @@
|
|
|
package org.elasticsearch.search.suggest;
|
|
|
|
|
|
import com.carrotsearch.randomizedtesting.generators.RandomStrings;
|
|
|
+
|
|
|
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
|
|
import org.elasticsearch.action.index.IndexRequestBuilder;
|
|
|
import org.elasticsearch.action.index.IndexResponse;
|
|
@@ -68,7 +69,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
}
|
|
|
|
|
|
public void testContextPrefix() throws Exception {
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
map.put("cat", ContextBuilder.category("cat").field("cat").build());
|
|
|
boolean addAnotherContext = randomBoolean();
|
|
|
if (addAnotherContext) {
|
|
@@ -99,7 +100,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
}
|
|
|
|
|
|
public void testContextRegex() throws Exception {
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
map.put("cat", ContextBuilder.category("cat").field("cat").build());
|
|
|
boolean addAnotherContext = randomBoolean();
|
|
|
if (addAnotherContext) {
|
|
@@ -130,7 +131,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
}
|
|
|
|
|
|
public void testContextFuzzy() throws Exception {
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
map.put("cat", ContextBuilder.category("cat").field("cat").build());
|
|
|
boolean addAnotherContext = randomBoolean();
|
|
|
if (addAnotherContext) {
|
|
@@ -162,7 +163,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
|
|
|
public void testContextFilteringWorksWithUTF8Categories() throws Exception {
|
|
|
CategoryContextMapping contextMapping = ContextBuilder.category("cat").field("cat").build();
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>(Collections.singletonMap("cat", contextMapping));
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>(Collections.singletonMap("cat", contextMapping));
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
|
createIndexAndMapping(mapping);
|
|
|
IndexResponse indexResponse = client().prepareIndex(INDEX, TYPE, "1")
|
|
@@ -183,7 +184,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
|
|
|
public void testSingleContextFiltering() throws Exception {
|
|
|
CategoryContextMapping contextMapping = ContextBuilder.category("cat").field("cat").build();
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>(Collections.singletonMap("cat", contextMapping));
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>(Collections.singletonMap("cat", contextMapping));
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
|
createIndexAndMapping(mapping);
|
|
|
int numDocs = 10;
|
|
@@ -209,7 +210,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
|
|
|
public void testSingleContextBoosting() throws Exception {
|
|
|
CategoryContextMapping contextMapping = ContextBuilder.category("cat").field("cat").build();
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>(Collections.singletonMap("cat", contextMapping));
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>(Collections.singletonMap("cat", contextMapping));
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
|
createIndexAndMapping(mapping);
|
|
|
int numDocs = 10;
|
|
@@ -237,7 +238,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
|
|
|
public void testSingleContextMultipleContexts() throws Exception {
|
|
|
CategoryContextMapping contextMapping = ContextBuilder.category("cat").field("cat").build();
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>(Collections.singletonMap("cat", contextMapping));
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>(Collections.singletonMap("cat", contextMapping));
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
|
createIndexAndMapping(mapping);
|
|
|
int numDocs = 10;
|
|
@@ -262,7 +263,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
}
|
|
|
|
|
|
public void testMultiContextFiltering() throws Exception {
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
map.put("cat", ContextBuilder.category("cat").field("cat").build());
|
|
|
map.put("type", ContextBuilder.category("type").field("type").build());
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
@@ -306,7 +307,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
|
|
|
@AwaitsFix(bugUrl = "multiple context boosting is broken, as a suggestion, contexts pair is treated as (num(context) entries)")
|
|
|
public void testMultiContextBoosting() throws Exception {
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
map.put("cat", ContextBuilder.category("cat").field("cat").build());
|
|
|
map.put("type", ContextBuilder.category("type").field("type").build());
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
@@ -361,7 +362,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
}
|
|
|
|
|
|
public void testMissingContextValue() throws Exception {
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
map.put("cat", ContextBuilder.category("cat").field("cat").build());
|
|
|
map.put("type", ContextBuilder.category("type").field("type").build());
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
@@ -391,7 +392,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
}
|
|
|
|
|
|
public void testSeveralContexts() throws Exception {
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
final int numContexts = randomIntBetween(2, 5);
|
|
|
for (int i = 0; i < numContexts; i++) {
|
|
|
map.put("type" + i, ContextBuilder.category("type" + i).field("type" + i).build());
|
|
@@ -421,7 +422,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
}
|
|
|
|
|
|
public void testSimpleGeoPrefix() throws Exception {
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
map.put("geo", ContextBuilder.geo("geo").build());
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
|
createIndexAndMapping(mapping);
|
|
@@ -446,7 +447,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
}
|
|
|
|
|
|
public void testGeoFiltering() throws Exception {
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
map.put("geo", ContextBuilder.geo("geo").build());
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
|
createIndexAndMapping(mapping);
|
|
@@ -478,7 +479,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
}
|
|
|
|
|
|
public void testGeoBoosting() throws Exception {
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
map.put("geo", ContextBuilder.geo("geo").build());
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
|
createIndexAndMapping(mapping);
|
|
@@ -511,7 +512,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
}
|
|
|
|
|
|
public void testGeoPointContext() throws Exception {
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
map.put("geo", ContextBuilder.geo("geo").build());
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
|
createIndexAndMapping(mapping);
|
|
@@ -551,7 +552,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
neighbours.add("gcpu");
|
|
|
neighbours.add("u10h");
|
|
|
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
map.put("geo", ContextBuilder.geo("geo").precision(4).build());
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
|
createIndexAndMapping(mapping);
|
|
@@ -640,7 +641,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
}
|
|
|
|
|
|
public void testSkipDuplicatesWithContexts() throws Exception {
|
|
|
- LinkedHashMap<String, ContextMapping> map = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
|
|
|
map.put("type", ContextBuilder.category("type").field("type").build());
|
|
|
map.put("cat", ContextBuilder.category("cat").field("cat").build());
|
|
|
final CompletionMappingBuilder mapping = new CompletionMappingBuilder().context(map);
|
|
@@ -706,7 +707,7 @@ public class ContextCompletionSuggestSearchIT extends ESIntegTestCase {
|
|
|
List<String> categoryContextFields = new ArrayList<>();
|
|
|
if (completionMappingBuilder.contextMappings != null) {
|
|
|
mapping.startArray("contexts");
|
|
|
- for (Map.Entry<String, ContextMapping> contextMapping : completionMappingBuilder.contextMappings.entrySet()) {
|
|
|
+ for (Map.Entry<String, ContextMapping<?>> contextMapping : completionMappingBuilder.contextMappings.entrySet()) {
|
|
|
mapping.startObject()
|
|
|
.field("name", contextMapping.getValue().name())
|
|
|
.field("type", contextMapping.getValue().type().name());
|