blob: f419ac6f915e875c649a2a38d7385f7f518eab9f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.derived;
import com.yahoo.schema.ApplicationBuilder;
import com.yahoo.search.config.IndexInfoConfig;
import org.junit.jupiter.api.Test;
import java.util.Set;
import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* @author bratseth
*/
public class CasedIndexTestCase {
@Test
public void testCasedIndexDeriving() throws Exception {
var b = new ApplicationBuilder();
b.addSchema("""
schema test {
document test {
field a type string {
indexing: summary | index
match: cased
}
}
}
""");
var application = b.build(true);
var config = new DerivedConfiguration(application.schemas().get("test"), b.getRankProfileRegistry());
var indexInfo = config.getIndexInfo();
var indexInfoConfigBuilder = new IndexInfoConfig.Builder();
indexInfo.getConfig(indexInfoConfigBuilder);
assertFalse(commandsOf("test", "a", indexInfoConfigBuilder).contains("lowercase"));
}
private Set<String> commandsOf(String schema, String field, IndexInfoConfig.Builder indexInfoConfigBuilder) {
var schemaIndexInfo = indexInfoConfigBuilder.build().indexinfo().stream()
.filter(c -> c.name().equals(schema))
.findAny().get();
return schemaIndexInfo.command().stream()
.filter(c -> c.indexname().equals(field))
.map(c -> c.command())
.collect(Collectors.toSet());
}
}
|