static TestQueryParser*
logical_test_nested_empty_parens(u32_t boolop)
{
    Query   *inner   = make_poly_query(boolop, NULL);
    Query   *tree    = make_poly_query(boolop, inner, NULL);
    return TestQP_new("(())", tree, NULL, 0);
}
Пример #2
0
static TestQueryParser*
syntax_test_unclosed_parens() {
    // Not a perfect result, but then it's not a good query string.
    Query *inner = make_poly_query(BOOLOP_OR, NULL);
    Query *tree = make_poly_query(BOOLOP_OR, inner, NULL);
    return TestQP_new("((", tree, NULL, 0);
}
Пример #3
0
static TestQueryParser*
logical_test_two_terms_one_nested(uint32_t boolop) {
    Query   *a_leaf    = make_leaf_query(NULL, "a");
    Query   *b_leaf    = make_leaf_query(NULL, "b");
    Query   *b_tree    = make_poly_query(boolop, b_leaf, NULL);
    Query   *tree      = make_poly_query(boolop, a_leaf, b_tree, NULL);
    uint32_t num_hits  = boolop == BOOLOP_OR ? 4 : 3;
    return TestQP_new("a (b)", tree, NULL, num_hits);
}
Пример #4
0
static TestQueryParser*
logical_test_one_term_one_nested_phrase(uint32_t boolop) {
    Query   *a_leaf     = make_leaf_query(NULL, "a");
    Query   *bc_leaf    = make_leaf_query(NULL, "\"b c\"");
    Query   *inner_tree = make_poly_query(boolop, bc_leaf, NULL);
    Query   *tree       = make_poly_query(boolop, a_leaf, inner_tree, NULL);
    uint32_t num_hits   = boolop == BOOLOP_OR ? 4 : 2;
    return TestQP_new("a (\"b c\")", tree, NULL, num_hits);
}
Пример #5
0
static TestQueryParser*
logical_test_nested_or(uint32_t boolop) {
    Query   *a_query = make_leaf_query(NULL, "a");
    Query   *b_query = make_leaf_query(NULL, "b");
    Query   *c_query = make_leaf_query(NULL, "c");
    Query   *nested  = make_poly_query(BOOLOP_OR, b_query, c_query, NULL);
    Query   *tree    = make_poly_query(boolop, a_query, nested, NULL);
    return TestQP_new("a (b OR c)", tree, NULL, boolop == BOOLOP_OR ? 4 : 3);
}
Пример #6
0
// Technically, this should produce an acceptably small result set, but it's
// too difficult to prune -- so QParser_Prune just lops it because it's a
// top-level NOTQuery.
static TestQueryParser*
logical_test_nested_negations(uint32_t boolop) {
    Query *query = make_leaf_query(NULL, "a");
    query = make_poly_query(boolop, query, NULL);
    query = make_not_query(query);
    query = make_poly_query(BOOLOP_AND, query, NULL);
    query = make_not_query(query);
    return TestQP_new("-(-(a))", query, NULL, 0);
}
Пример #7
0
static TestQueryParser*
prune_test_not_and_not() {
    Query   *a_leaf  = make_leaf_query(NULL, "a");
    Query   *b_leaf  = make_leaf_query(NULL, "b");
    Query   *not_a   = make_not_query(a_leaf);
    Query   *not_b   = make_not_query(b_leaf);
    Query   *tree    = make_poly_query(BOOLOP_AND, not_a, not_b, NULL);
    Query   *pruned  = make_poly_query(BOOLOP_AND, NULL);
    return TestQP_new(NULL, tree, pruned, 0);
}
static TestQueryParser*
logical_test_one_term_one_nested_single_term_phrase(u32_t boolop)
{
    Query   *a_leaf    = make_leaf_query(NULL, "a");
    Query   *b_leaf    = make_leaf_query(NULL, "\"b\"");
    Query   *b_tree    = make_poly_query(boolop, b_leaf, NULL);
    Query   *tree      = make_poly_query(boolop, a_leaf, b_tree, NULL);
    u32_t    num_hits  = boolop == BOOLOP_OR ? 4 : 3;
    return TestQP_new("a (\"b\")", tree, NULL, num_hits);
}
Пример #9
0
static TestQueryParser*
logical_test_and_nested_or(uint32_t boolop) {
    Query   *a_query = make_leaf_query(NULL, "a");
    Query   *b_query = make_leaf_query(NULL, "b");
    Query   *c_query = make_leaf_query(NULL, "c");
    Query   *nested  = make_poly_query(BOOLOP_OR, b_query, c_query, NULL);
    Query   *tree    = make_poly_query(BOOLOP_AND, a_query, nested, NULL);
    UNUSED_VAR(boolop);
    return TestQP_new("a AND (b OR c)", tree, NULL, 3);
}
static TestQueryParser*
logical_test_three_terms_two_nested(u32_t boolop)
{
    Query   *a_leaf     = make_leaf_query(NULL, "a");
    Query   *b_leaf     = make_leaf_query(NULL, "b");
    Query   *c_leaf     = make_leaf_query(NULL, "c");
    Query   *inner_tree = make_poly_query(boolop, b_leaf, c_leaf, NULL);
    Query   *tree       = make_poly_query(boolop, a_leaf, inner_tree, NULL);
    u32_t    num_hits   = boolop == BOOLOP_OR ? 4 : 2;
    return TestQP_new("a (b c)", tree, NULL, num_hits);
}
Пример #11
0
static TestQueryParser*
prune_test_optional_not() {
    Query   *a_leaf  = make_leaf_query(NULL, "a");
    Query   *b_leaf  = make_leaf_query(NULL, "b");
    Query   *not_b   = make_not_query(b_leaf);
    Query   *tree    = make_poly_query(BOOLOP_OR, (Query*)INCREF(a_leaf),
                                       not_b, NULL);
    Query   *nomatch = (Query*)NoMatchQuery_new();
    Query   *pruned  = make_poly_query(BOOLOP_OR, a_leaf, nomatch, NULL);
    return TestQP_new(NULL, tree, pruned, 4);
}
Пример #12
0
static TestQueryParser*
logical_test_a_OR_b_AND_c_OR_d(uint32_t boolop) {
    Query *a_query    = make_leaf_query(NULL, "a");
    Query *b_query    = make_leaf_query(NULL, "b");
    Query *c_query    = make_leaf_query(NULL, "c");
    Query *d_query    = make_leaf_query(NULL, "d");
    Query *middle     = make_poly_query(BOOLOP_AND, b_query, c_query, NULL);
    Query *tree       = make_poly_query(BOOLOP_OR, a_query, middle, d_query,
                                        NULL);
    UNUSED_VAR(boolop);
    return TestQP_new("a OR b AND c OR d", tree, NULL, 4);
}
Пример #13
0
static TestQueryParser*
logical_test_a_OR_b_OR_c_AND_d(uint32_t boolop) {
    Query *a_query    = make_leaf_query(NULL, "a");
    Query *b_query    = make_leaf_query(NULL, "b");
    Query *c_query    = make_leaf_query(NULL, "c");
    Query *d_query    = make_leaf_query(NULL, "d");
    Query *right      = make_poly_query(BOOLOP_AND, c_query, d_query, NULL);
    Query *tree       = make_poly_query(BOOLOP_OR, a_query, b_query, right,
                                        NULL);
    UNUSED_VAR(boolop);
    return TestQP_new("a OR b OR c AND d", tree, NULL, 4);
}
Пример #14
0
static TestQueryParser*
logical_test_a_AND_b_OR_c_d(uint32_t boolop) {
    Query *a_query    = make_leaf_query(NULL, "a");
    Query *b_query    = make_leaf_query(NULL, "b");
    Query *c_query    = make_leaf_query(NULL, "c");
    Query *d_query    = make_leaf_query(NULL, "d");
    Query *inner      = make_poly_query(BOOLOP_AND, a_query, b_query, NULL);
    Query *left       = make_poly_query(BOOLOP_OR, inner, c_query, NULL);
    Query *tree       = make_poly_query(boolop, left, d_query, NULL);
    uint32_t num_hits = boolop == BOOLOP_AND ? 1 : 3;
    return TestQP_new("a AND b OR c d", tree, NULL, num_hits);
}
Пример #15
0
static TestQueryParser*
logical_test_a_OR_b_c_AND_d(uint32_t boolop) {
    Query *a_query    = make_leaf_query(NULL, "a");
    Query *b_query    = make_leaf_query(NULL, "b");
    Query *c_query    = make_leaf_query(NULL, "c");
    Query *d_query    = make_leaf_query(NULL, "d");
    Query *left       = make_poly_query(BOOLOP_OR, a_query, b_query, NULL);
    Query *right      = make_poly_query(BOOLOP_AND, c_query, d_query, NULL);
    Query *tree       = make_poly_query(boolop, left, right, NULL);
    uint32_t num_hits = boolop == BOOLOP_AND ? 1 : 4;
    return TestQP_new("a OR b c AND d", tree, NULL, num_hits);
}
Пример #16
0
static TestQueryParser*
logical_test_a_b_OR_c_OR_d(uint32_t boolop) {
    Query *a_query    = make_leaf_query(NULL, "a");
    Query *b_query    = make_leaf_query(NULL, "b");
    Query *c_query    = make_leaf_query(NULL, "c");
    Query *d_query    = make_leaf_query(NULL, "d");
    Query *right      = make_poly_query(BOOLOP_OR, b_query, c_query, d_query,
                                        NULL);
    Query *tree       = make_poly_query(boolop, a_query, right, NULL);
    uint32_t num_hits = boolop == BOOLOP_AND ? 3 : 4;
    return TestQP_new("a b OR c OR d", tree, NULL, num_hits);
}
Пример #17
0
static TestQueryParser*
logical_test_a_AND_b_OR_c_OR_d(uint32_t boolop) {
    Query *a_query    = make_leaf_query(NULL, "a");
    Query *b_query    = make_leaf_query(NULL, "b");
    Query *c_query    = make_leaf_query(NULL, "c");
    Query *d_query    = make_leaf_query(NULL, "d");
    Query *left       = make_poly_query(BOOLOP_AND, a_query, b_query, NULL);
    Query *tree       = make_poly_query(BOOLOP_OR, left, c_query, d_query,
                                        NULL);
    UNUSED_VAR(boolop);
    return TestQP_new("a AND b OR c OR d", tree, NULL, 3);
}
Пример #18
0
static TestQueryParser*
logical_test_nested_nest(uint32_t boolop) {
    Query *a_query    = make_leaf_query(NULL, "a");
    Query *b_query    = make_leaf_query(NULL, "b");
    Query *c_query    = make_leaf_query(NULL, "c");
    Query *d_query    = make_leaf_query(NULL, "d");
    Query *innermost  = make_poly_query(BOOLOP_AND, c_query, d_query, NULL);
    Query *inner      = make_poly_query(BOOLOP_OR, b_query, innermost, NULL);
    Query *not_inner  = make_not_query(inner);
    Query *tree       = make_poly_query(BOOLOP_AND, a_query, not_inner, NULL);
    UNUSED_VAR(boolop);
    return TestQP_new("a AND NOT (b OR (c AND d))", tree, NULL, 1);
}
static TestQueryParser*
logical_test_one_nested_term(u32_t boolop)
{
    Query   *leaf   = make_leaf_query(NULL, "a");
    Query   *tree   = make_poly_query(boolop, leaf, NULL);
    return TestQP_new("(a)", tree, NULL, 4);
}
Пример #20
0
static TestQueryParser*
syntax_test_padded_minus() {
    Query *minus = make_leaf_query(NULL, "-");
    Query *a = make_leaf_query(NULL, "a");
    Query *tree = make_poly_query(BOOLOP_OR, minus, a, NULL);
    return TestQP_new("- a", tree, NULL, 4);
}
static TestQueryParser*
logical_test_nested_empty_phrase(u32_t boolop)
{
    Query   *leaf   = make_leaf_query(NULL, "\"\"");
    Query   *tree   = make_poly_query(boolop, leaf, NULL);
    return TestQP_new("(\"\")", tree, NULL, 0);
}
Пример #22
0
static TestQueryParser*
leaf_test_phrase_with_stopwords() {
    Query   *tree     = make_leaf_query(NULL, "\"x a\"");
    Query   *plain_q  = make_phrase_query("plain", "x", "a", NULL);
    Query   *fancy_q  = make_phrase_query("fancy", "a", NULL);
    Query   *expanded = make_poly_query(BOOLOP_OR, fancy_q, plain_q, NULL);
    return TestQP_new("\"x a\"", tree, expanded, 4);
}
Пример #23
0
static TestQueryParser*
leaf_test_escaped_quotes_outside() {
    Query   *tree = make_leaf_query(NULL, "\\\"a");
    Query   *plain_q  = make_term_query("plain", "\"a");
    Query   *fancy_q  = make_term_query("fancy", "a");
    Query   *expanded = make_poly_query(BOOLOP_OR, fancy_q, plain_q, NULL);
    return TestQP_new("\\\"a", tree, expanded, 4);
}
Пример #24
0
static TestQueryParser*
leaf_test_different_tokenization() {
    Query   *tree     = make_leaf_query(NULL, "a.b");
    Query   *plain_q  = make_term_query("plain", "a.b");
    Query   *fancy_q  = make_phrase_query("fancy", "a", "b", NULL);
    Query   *expanded = make_poly_query(BOOLOP_OR, fancy_q, plain_q, NULL);
    return TestQP_new("a.b", tree, expanded, 3);
}
Пример #25
0
static TestQueryParser*
logical_test_field_bool_group(uint32_t boolop) {
    Query   *b_query = make_leaf_query("content", "b");
    Query   *c_query = make_leaf_query("content", "c");
    Query   *tree    = make_poly_query(boolop, b_query, c_query, NULL);
    return TestQP_new("content:(b c)", tree, NULL,
                      boolop == BOOLOP_OR ? 3 : 2);
}
Пример #26
0
static TestQueryParser*
leaf_test_unclosed_quote() {
    Query   *tree     = make_leaf_query(NULL, "\"a b");
    Query   *plain_q  = make_phrase_query("plain", "a", "b", NULL);
    Query   *fancy_q  = make_phrase_query("fancy", "a", "b", NULL);
    Query   *expanded = make_poly_query(BOOLOP_OR, fancy_q, plain_q, NULL);
    return TestQP_new("\"a b", tree, expanded, 3);
}
Пример #27
0
static TestQueryParser*
leaf_test_simple_term() {
    Query   *tree     = make_leaf_query(NULL, "a");
    Query   *plain_q  = make_term_query("plain", "a");
    Query   *fancy_q  = make_term_query("fancy", "a");
    Query   *expanded = make_poly_query(BOOLOP_OR, fancy_q, plain_q, NULL);
    return TestQP_new("a", tree, expanded, 4);
}
Пример #28
0
static TestQueryParser*
logical_test_intersection(uint32_t boolop) {
    Query   *a_query = make_leaf_query(NULL, "a");
    Query   *b_query = make_leaf_query(NULL, "b");
    Query   *tree    = make_poly_query(BOOLOP_AND, a_query, b_query, NULL);
    UNUSED_VAR(boolop);
    return TestQP_new("a AND b", tree, NULL, 3);
}
Пример #29
0
static TestQueryParser*
logical_test_a_or_plus_b(uint32_t boolop) {
    Query   *a_query = make_leaf_query(NULL, "a");
    Query   *b_query = make_leaf_query(NULL, "b");
    Query   *tree    = make_poly_query(BOOLOP_OR, a_query, b_query, NULL);
    UNUSED_VAR(boolop);
    return TestQP_new("a OR +b", tree, NULL, 4);
}
Пример #30
0
static TestQueryParser*
leaf_test_empty_phrase() {
    Query   *tree     = make_leaf_query(NULL, "\"\"");
    Query   *plain_q  = make_phrase_query("plain", NULL);
    Query   *fancy_q  = make_phrase_query("fancy", NULL);
    Query   *expanded = make_poly_query(BOOLOP_OR, fancy_q, plain_q, NULL);
    return TestQP_new("\"\"", tree, expanded, 0);
}