aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/schema/IndexSettingsTestCase.java
blob: 10039849b0f7b06805fd19d143cec9a613bedb5d (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
60
61
62
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema;

import com.yahoo.schema.document.SDField;
import com.yahoo.schema.document.Stemming;
import com.yahoo.schema.parser.ParseException;
import org.junit.jupiter.api.Test;

import java.io.IOException;

import static com.yahoo.config.model.test.TestUtil.joinLines;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
 * Rank settings
 *
 * @author bratseth
 */
public class IndexSettingsTestCase extends AbstractSchemaTestCase {

    @Test
    void testStemmingSettings() throws IOException, ParseException {
        Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/indexsettings.sd");

        SDField usingDefault = (SDField) schema.getDocument().getField("usingdefault");
        assertEquals(Stemming.SHORTEST, usingDefault.getStemming(schema));

        SDField notStemmed = (SDField) schema.getDocument().getField("notstemmed");
        assertEquals(Stemming.NONE, notStemmed.getStemming(schema));

        SDField allStemmed = (SDField) schema.getDocument().getField("allstemmed");
        assertEquals(Stemming.SHORTEST, allStemmed.getStemming(schema));

        SDField multiStemmed = (SDField) schema.getDocument().getField("multiplestems");
        assertEquals(Stemming.MULTIPLE, multiStemmed.getStemming(schema));
    }

    @Test
    void requireThatInterleavedFeaturesAreSetOnExtraField() throws ParseException {
        ApplicationBuilder builder = ApplicationBuilder.createFromString(joinLines(
                "search test {",
                "  document test {",
                "    field content type string {",
                "      indexing: index | summary",
                "      index: enable-bm25",
                "    }",
                "  }",
                "  field extra type string {",
                "    indexing: input content | index | summary",
                "    index: enable-bm25",
                "  }",
                "}"
        ));
        Schema schema = builder.getSchema();
        Index contentIndex = schema.getIndex("content");
        assertTrue(contentIndex.useInterleavedFeatures());
        Index extraIndex = schema.getIndex("extra");
        assertTrue(extraIndex.useInterleavedFeatures());
    }

}