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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.derived;
import com.yahoo.component.ComponentId;
import com.yahoo.search.Query;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry;
import com.yahoo.search.query.profile.config.QueryProfileConfigurer;
import com.yahoo.schema.parser.ParseException;
import com.yahoo.vespa.model.container.search.QueryProfiles;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
public class NearestNeighborTestCase extends AbstractExportingTestCase {
@Test
public void testNearestNeighbor() throws IOException, ParseException {
try {
ComponentId.resetGlobalCountersForTests();
DerivedConfiguration c = assertCorrectDeriving("nearestneighbor");
CompiledQueryProfileRegistry queryProfiles =
QueryProfileConfigurer.createFromConfig(new QueryProfiles(c.getQueryProfiles(), (level, message) -> {}).getConfig()).compile();
Query q = new Query("?ranking.features.query(q_vec)=[1,2,3,4,5,6]", // length is 6, not 5
queryProfiles.getComponent("default"));
fail("This should fail when q_vec is parsed as a tensor");
} catch (IllegalArgumentException e) {
// success
assertEquals("Could not set 'ranking.features.query(q_vec)' to '[1,2,3,4,5,6]'", e.getMessage());
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
}
}
|