aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude/semantics/test/LabelMatchingTestCase.java
blob: d45e114e89fabc42a92a41e3808bbd945650010f (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.test;

import java.io.IOException;

import com.yahoo.prelude.semantics.parser.ParseException;
import org.junit.Test;

/**
 * Tests label-dependent matching
 *
 * @author bratseth
 */
public class LabelMatchingTestCase extends RuleBaseAbstractTestCase {

    public LabelMatchingTestCase() {
        super("labelmatching.sr");
    }

    /** Tests that matching with no label matches the default label (index) only */
    @Test
    public void testDefaultLabelMatching() throws IOException, ParseException {
        assertSemantics("matched:term","term");
        assertSemantics("alabel:term","alabel:term");

        assertSemantics("AND term2 hit","term2");
        assertSemantics("alabel:term2","alabel:term2");
    }

    @Test
    public void testSpecificLabelMatchingInConditionReference() throws IOException, ParseException {
        assertSemantics("+dcattitle:restaurants -dcat:hotel","dcattitle:restaurants");
    }

    @Test
    public void testSpecificlabelMatchingInNestedCondition() throws IOException, ParseException {
        assertSemantics("three","foo:one");
        assertSemantics("three","foo:two");
        assertSemantics("bar:one","bar:one");
        assertSemantics("bar:two","bar:two");
        assertSemantics("foo:three","foo:three");
        assertSemantics("one","one");
        assertSemantics("two","two");
        assertSemantics("AND three three","foo:one foo:two");
        assertSemantics("AND bar:one bar:two","bar:one bar:two");
    }

}