use of com.yahoo.prelude.Index in project vespa by vespa-engine.
the class ParseTestCase method testExactMatchParsing1.
@Test
public void testExactMatchParsing1() {
IndexFacts indexFacts = ParsingTester.createIndexFacts();
Index index1 = new Index("testexact1");
index1.setExact(true, null);
Index index2 = new Index("testexact2");
index2.setExact(true, "()/aa*::*&");
indexFacts.addIndex("testsd", index1);
indexFacts.addIndex("testsd", index2);
ParsingTester customTester = new ParsingTester(indexFacts);
customTester.assertParsed("testexact1:/,%&#", "testexact1:/,%&#", Query.Type.ALL);
customTester.assertParsed("testexact2:/,%&#!!", "testexact2:/,%&#!!()/aa*::*&", Query.Type.ALL);
customTester.assertParsed("AND word1 (OR testexact1:word2 testexact1:word3)", "word1 AND (testexact1:word2 OR testexact1:word3 )", Query.Type.ADVANCED);
customTester.assertParsed("AND word (OR testexact1:AND testexact1:OR)", "word AND (testexact1: AND OR testexact1: OR )", Query.Type.ADVANCED);
}
use of com.yahoo.prelude.Index in project vespa by vespa-engine.
the class ParseTestCase method testExactMatchParsing2.
/**
* Testing terminators containing control characters in conjunction with those control characters
*/
@Test
public void testExactMatchParsing2() {
IndexFacts indexFacts = ParsingTester.createIndexFacts();
Index index1 = new Index("testexact1");
index1.setExact(true, "*!*");
indexFacts.addIndex("testsd", index1);
ParsingTester customTester = new ParsingTester(indexFacts);
customTester.assertParsed("testexact1:_-_*!200", "testexact1:_-_*!**!!", Query.Type.ALL);
}
use of com.yahoo.prelude.Index in project vespa by vespa-engine.
the class ParseTestCase method testExactMatchParsing3.
/**
* Testing terminators containing control characters in conjunction with those control characters
*/
@Test
public void testExactMatchParsing3() {
IndexFacts indexFacts = ParsingTester.createIndexFacts();
Index index1 = new Index("testexact1");
index1.setExact(true, "*");
indexFacts.addIndex("testsd", index1);
ParsingTester customTester = new ParsingTester(indexFacts);
customTester.assertParsed("testexact1:_-_*!200", "testexact1:_-_**!!", Query.Type.ALL);
}
use of com.yahoo.prelude.Index in project vespa by vespa-engine.
the class TokenizerTestCase method testExactMatchTokenizationEndsByColon.
@Test
public void testExactMatchTokenizationEndsByColon() {
Index index1 = new Index("testexact1");
index1.setExact(true, null);
Index index2 = new Index("testexact2");
index2.setExact(true, "()/aa*::*&");
IndexFacts facts = new IndexFacts();
facts.addIndex("testsd", index1);
facts.addIndex("testsd", index2);
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
IndexFacts.Session session = facts.newSession(Collections.emptySet(), Collections.emptySet());
List<?> tokens = tokenizer.tokenize("normal a:b (normal testexact1:!/%#%&+-+ ) testexact2:ho_/&%&/()/aa*::*&b:", session);
assertEquals(new Token(WORD, "normal"), tokens.get(0));
assertEquals(new Token(SPACE, " "), tokens.get(1));
assertEquals(new Token(WORD, "a"), tokens.get(2));
assertEquals(new Token(COLON, ":"), tokens.get(3));
assertEquals(new Token(WORD, "b"), tokens.get(4));
assertEquals(new Token(SPACE, " "), tokens.get(5));
assertEquals(new Token(LBRACE, "("), tokens.get(6));
assertEquals(new Token(WORD, "normal"), tokens.get(7));
assertEquals(new Token(SPACE, " "), tokens.get(8));
assertEquals(new Token(WORD, "testexact1"), tokens.get(9));
assertEquals(new Token(COLON, ":"), tokens.get(10));
assertEquals(new Token(WORD, "!/%#%&+-+"), tokens.get(11));
assertEquals(new Token(SPACE, " "), tokens.get(12));
assertEquals(new Token(RBRACE, ")"), tokens.get(13));
assertEquals(new Token(SPACE, " "), tokens.get(14));
assertEquals(new Token(WORD, "testexact2"), tokens.get(15));
assertEquals(new Token(COLON, ":"), tokens.get(16));
assertEquals(new Token(WORD, "ho_/&%&/"), tokens.get(17));
assertEquals(new Token(WORD, "b"), tokens.get(18));
assertEquals(new Token(COLON, ":"), tokens.get(19));
}
use of com.yahoo.prelude.Index in project vespa by vespa-engine.
the class TokenizerTestCase method testExactMatchTokenizationWithTerminatorTerminatedByEndOfString.
@Test
public void testExactMatchTokenizationWithTerminatorTerminatedByEndOfString() {
Index index1 = new Index("testexact1");
index1.setExact(true, null);
Index index2 = new Index("testexact2");
index2.setExact(true, "()/aa*::*&");
IndexFacts facts = new IndexFacts();
facts.addIndex("testsd", index1);
facts.addIndex("testsd", index2);
Tokenizer tokenizer = new Tokenizer(new SimpleLinguistics());
IndexFacts.Session session = facts.newSession(Collections.emptySet(), Collections.emptySet());
List<?> tokens = tokenizer.tokenize("normal a:b (normal testexact1:/,%#%&+-+ ) testexact2:ho_/&%&/()/aa*::*", session);
assertEquals(new Token(WORD, "normal"), tokens.get(0));
assertEquals(new Token(SPACE, " "), tokens.get(1));
assertEquals(new Token(WORD, "a"), tokens.get(2));
assertEquals(new Token(COLON, ":"), tokens.get(3));
assertEquals(new Token(WORD, "b"), tokens.get(4));
assertEquals(new Token(SPACE, " "), tokens.get(5));
assertEquals(new Token(LBRACE, "("), tokens.get(6));
assertEquals(new Token(WORD, "normal"), tokens.get(7));
assertEquals(new Token(SPACE, " "), tokens.get(8));
assertEquals(new Token(WORD, "testexact1"), tokens.get(9));
assertEquals(new Token(COLON, ":"), tokens.get(10));
assertEquals(new Token(WORD, "/,%#%&+-+"), tokens.get(11));
assertEquals(new Token(SPACE, " "), tokens.get(12));
assertEquals(new Token(RBRACE, ")"), tokens.get(13));
assertEquals(new Token(SPACE, " "), tokens.get(14));
assertEquals(new Token(WORD, "testexact2"), tokens.get(15));
assertEquals(new Token(COLON, ":"), tokens.get(16));
assertEquals(new Token(WORD, "ho_/&%&/()/aa*::*"), tokens.get(17));
assertTrue(((Token) tokens.get(17)).isSpecial());
}
Aggregations