blob: 9118c1909a15c601a85f6119d27a725b2ae9b88f (
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
50
51
52
53
54
55
56
57
58
59
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.processing;
import com.yahoo.schema.ApplicationBuilder;
import com.yahoo.schema.parser.ParseException;
import com.yahoo.yolean.Exceptions;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
*/
public class IndexingValuesTestCase {
@Test
void requireThatModifyFieldNoOutputDoesNotThrow() throws ParseException {
var schema = """
search indexing_modify_field_no_output {
document indexing_modify_field_no_output {
field foo type string {
indexing: lowercase | echo
}
}
}
""";
ApplicationBuilder.createFromString(schema);
}
@Test
void requireThatInputOtherFieldThrows() throws IOException, ParseException {
try {
var schema = """
search indexing_input_other_field {
document indexing_input_other_field {
field foo type string {
}
field bar type string {
indexing: input foo | attribute | index | summary
}
}
}
""";
ApplicationBuilder.createFromString(schema);
fail("Expected exception");
}
catch (IllegalArgumentException e) {
assertEquals("For schema 'indexing_input_other_field', field 'bar': Indexing expression 'input foo' " +
"attempts to modify the value of the document field 'bar'. " +
"Use a field outside the document block instead.",
Exceptions.toMessageString(e));
}
}
}
|