use of io.crate.expression.symbol.MatchPredicate in project crate by crate.
the class SelectStatementAnalyzerTest method testMatchOnIndex.
@Test
public void testMatchOnIndex() throws Exception {
var executor = SQLExecutor.builder(clusterService).addTable(TableDefinitions.USER_TABLE_DEFINITION).build();
QueriedSelectRelation relation = executor.analyze("select * from users where match(name_text_ft, 'Arthur Dent')");
assertThat(relation.where(), instanceOf(MatchPredicate.class));
MatchPredicate match = (MatchPredicate) relation.where();
assertThat(match.identBoostMap(), hasEntry(isReference("name_text_ft"), isLiteral(null)));
assertThat(match.queryTerm(), isLiteral("Arthur Dent"));
assertThat(match.matchType(), is("best_fields"));
assertThat(match.options(), isLiteral(Map.of()));
}
use of io.crate.expression.symbol.MatchPredicate in project crate by crate.
the class SelectStatementAnalyzerTest method testWhereMatchOnColumn.
@Test
public void testWhereMatchOnColumn() throws Exception {
var executor = SQLExecutor.builder(clusterService).addTable(TableDefinitions.USER_TABLE_DEFINITION).build();
QueriedSelectRelation relation = executor.analyze("select * from users where match(name, 'Arthur Dent')");
assertThat(relation.where(), Matchers.instanceOf(MatchPredicate.class));
MatchPredicate matchPredicate = (MatchPredicate) relation.where();
assertThat(matchPredicate.queryTerm(), isLiteral("Arthur Dent"));
assertThat(matchPredicate.identBoostMap(), hasEntry(isReference("name"), isLiteral(null)));
assertThat(matchPredicate.matchType(), is("best_fields"));
assertThat(matchPredicate.options(), isLiteral(Map.of()));
}
use of io.crate.expression.symbol.MatchPredicate in project crate by crate.
the class SelectStatementAnalyzerTest method testSelectWhereFullMatchPredicate.
@Test
public void testSelectWhereFullMatchPredicate() throws Exception {
var executor = SQLExecutor.builder(clusterService).addTable(TableDefinitions.USER_TABLE_DEFINITION).build();
QueriedSelectRelation relation = executor.analyze("select * from users " + "where match ((name 1.2, text), 'awesome') using best_fields with (analyzer='german')");
Symbol query = relation.where();
assertThat(query, instanceOf(MatchPredicate.class));
MatchPredicate match = (MatchPredicate) query;
assertThat(match.identBoostMap(), hasEntry(isReference("name"), isLiteral(1.2)));
assertThat(match.identBoostMap(), hasEntry(isReference("text"), isLiteral(null)));
assertThat(match.queryTerm(), isLiteral("awesome"));
assertThat(match.matchType(), is("best_fields"));
assertThat(match.options(), isLiteral(Map.of("analyzer", "german")));
}
use of io.crate.expression.symbol.MatchPredicate in project crate by crate.
the class SingleRowSubselectAnalyzerTest method testMatchPredicateWithSingleRowSubselect.
@Test
public void testMatchPredicateWithSingleRowSubselect() throws Exception {
QueriedSelectRelation relation = e.analyze("select * from users where match(shape 1.2, (select shape from users limit 1))");
assertThat(relation.where(), instanceOf(MatchPredicate.class));
MatchPredicate match = (MatchPredicate) relation.where();
assertThat(match.identBoostMap(), hasEntry(isReference("shape"), isLiteral(1.2)));
assertThat(match.queryTerm(), instanceOf(SelectSymbol.class));
assertThat(match.matchType(), is("intersects"));
}
use of io.crate.expression.symbol.MatchPredicate in project crate by crate.
the class SelectStatementAnalyzerTest method testWhereMatchAllOptions.
@Test
public void testWhereMatchAllOptions() throws Exception {
var executor = SQLExecutor.builder(clusterService).addTable(TableDefinitions.USER_TABLE_DEFINITION).build();
QueriedSelectRelation relation = executor.analyze("select * from users " + "where match ((name 1.2, text), 'awesome') using best_fields with " + "(" + " analyzer='german'," + " boost=4.6," + " tie_breaker=0.75," + " operator='or'," + " minimum_should_match=4," + " fuzziness=12," + " max_expansions=3," + " prefix_length=4," + " rewrite='constant_score_boolean'," + " fuzzy_rewrite='top_terms_20'," + " zero_terms_query='all'," + " cutoff_frequency=5," + " slop=3" + ")");
MatchPredicate match = (MatchPredicate) relation.where();
assertThat(match.options(), isLiteral(Map.ofEntries(Map.entry("analyzer", "german"), Map.entry("boost", 4.6), Map.entry("cutoff_frequency", 5), Map.entry("fuzziness", 12), Map.entry("fuzzy_rewrite", "top_terms_20"), Map.entry("max_expansions", 3), Map.entry("minimum_should_match", 4), Map.entry("operator", "or"), Map.entry("prefix_length", 4), Map.entry("rewrite", "constant_score_boolean"), Map.entry("slop", 3), Map.entry("tie_breaker", 0.75), Map.entry("zero_terms_query", "all"))));
}
Aggregations