use of org.apache.lucene.util.BytesRef in project crate by crate.
the class MatchQueryBuilderTest method testPhrasePrefix.
@Test
public void testPhrasePrefix() throws Exception {
MatchQueryBuilder builder = new MatchQueryBuilder(mockMapperService(), new BytesRef("phrase_prefix"), Collections.emptyMap());
Map<String, Object> fields = MapBuilder.<String, Object>newMapBuilder().put("col1", null).map();
Query query = builder.query(fields, new BytesRef("foo"));
assertThat(query, instanceOf(MultiPhrasePrefixQuery.class));
}
use of org.apache.lucene.util.BytesRef in project crate by crate.
the class MatchQueryBuilderTest method testUnknownMatchType.
@Test
public void testUnknownMatchType() throws Exception {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Unknown matchType \"foo\". Possible matchTypes are: best_fields, most_fields, cross_fields, phrase, phrase_prefix");
new MatchQueryBuilder(null, new BytesRef("foo"), Collections.emptyMap());
}
use of org.apache.lucene.util.BytesRef in project crate by crate.
the class MatchQueryBuilderTest method testSingleFieldWithCutFrequency.
@Test
public void testSingleFieldWithCutFrequency() throws Exception {
MatchQueryBuilder builder = new MatchQueryBuilder(mockMapperService(), null, newMapBuilder().put("cutoff_frequency", 3).map());
Map<String, Object> fields = MapBuilder.<String, Object>newMapBuilder().put("col1", null).map();
Query query = builder.query(fields, new BytesRef("foo bar"));
assertThat(query, instanceOf(ExtendedCommonTermsQuery.class));
}
use of org.apache.lucene.util.BytesRef in project crate by crate.
the class TableIdentTest method testFromIndexName.
@Test
public void testFromIndexName() throws Exception {
assertThat(TableIdent.fromIndexName("t"), is(new TableIdent(null, "t")));
assertThat(TableIdent.fromIndexName("s.t"), is(new TableIdent("s", "t")));
PartitionName pn = new PartitionName("s", "t", ImmutableList.of(new BytesRef("v1")));
assertThat(TableIdent.fromIndexName(pn.asIndexName()), is(new TableIdent("s", "t")));
pn = new PartitionName(null, "t", ImmutableList.of(new BytesRef("v1")));
assertThat(TableIdent.fromIndexName(pn.asIndexName()), is(new TableIdent(null, "t")));
}
use of org.apache.lucene.util.BytesRef in project crate by crate.
the class PartitionNameTest method testFromIndexOrTemplate.
@Test
public void testFromIndexOrTemplate() throws Exception {
PartitionName partitionName = new PartitionName("t", Arrays.asList(new BytesRef("a"), new BytesRef("b")));
assertThat(partitionName, equalTo(PartitionName.fromIndexOrTemplate(partitionName.asIndexName())));
partitionName = new PartitionName(null, "t", Arrays.asList(new BytesRef("a"), new BytesRef("b")));
assertThat(partitionName, equalTo(PartitionName.fromIndexOrTemplate(partitionName.asIndexName())));
assertThat(partitionName.ident(), is("081620j2"));
partitionName = new PartitionName("schema", "t", Arrays.asList(new BytesRef("a"), new BytesRef("b")));
assertThat(partitionName, equalTo(PartitionName.fromIndexOrTemplate(partitionName.asIndexName())));
assertThat(partitionName.ident(), is("081620j2"));
partitionName = new PartitionName(null, "t", Collections.singletonList(new BytesRef("hoschi")));
assertThat(partitionName, equalTo(PartitionName.fromIndexOrTemplate(partitionName.asIndexName())));
assertThat(partitionName.ident(), is("043mgrrjcdk6i"));
partitionName = new PartitionName(null, "t", Collections.<BytesRef>singletonList(null));
assertThat(partitionName, equalTo(PartitionName.fromIndexOrTemplate(partitionName.asIndexName())));
assertThat(partitionName.ident(), is("0400"));
}
Aggregations