예제 #1
0
파일: rpn2solr.c 프로젝트: mekentosj/yazpp
static int rpn2solr_structure(solr_transform_t ct,
                              void (*pr)(const char *buf, void *client_data),
                              void *client_data,
                              Z_RPNStructure *q, int nested,
                              WRBUF w)
{
    if (q->which == Z_RPNStructure_simple)
    {
        if (q->u.simple->which != Z_Operand_APT)
            return YAZ_BIB1_RESULT_SET_UNSUPP_AS_A_SEARCH_TERM;
        else
            return rpn2solr_simple(ct, pr, client_data,
                                   q->u.simple->u.attributesPlusTerm, w, 0);
    }
    else
    {
        Z_Operator *op = q->u.complex->roperator;
        Z_AttributesPlusTerm *apt1, *apt2;
        int r;

        if (check_range(ct, q->u.complex, &apt1, &apt2))
            return rpn2solr_simple(ct, pr, client_data, apt1, w, apt2);
        if (nested)
            pr("(", client_data);

        r = rpn2solr_structure(ct, pr, client_data, q->u.complex->s1, 1, w);
        if (r)
            return r;
        switch (op->which)
        {
        case Z_Operator_and:
            pr(" AND ", client_data);
            break;
        case Z_Operator_or:
            pr(" OR ", client_data);
            break;
        case Z_Operator_and_not:
            pr(" AND NOT ", client_data);
            break;
        case Z_Operator_prox:
            return YAZ_BIB1_UNSUPP_SEARCH;
        }
        r = rpn2solr_structure(ct, pr, client_data, q->u.complex->s2, 1, w);
        if (nested)
            pr(")", client_data);
        return r;
    }
}
예제 #2
0
파일: rpn2solr.c 프로젝트: nla/yaz
static int rpn2solr_structure(solr_transform_t ct,
                              void (*pr)(const char *buf, void *client_data),
                              void *client_data,
                              Z_RPNStructure *q, int nested,
                              WRBUF w)
{
    if (q->which == Z_RPNStructure_simple)
        return rpn2solr_simple(ct, pr, client_data, q->u.simple, w);
    else
    {
        Z_Operator *op = q->u.complex->roperator;
        int r;

        if (nested)
            pr("(", client_data);

        r = rpn2solr_structure(ct, pr, client_data, q->u.complex->s1, 1, w);
        if (r)
            return r;
        switch(op->which)
        {
        case  Z_Operator_and:
            pr(" AND ", client_data);
            break;
        case  Z_Operator_or:
            pr(" OR ", client_data);
            break;
        case  Z_Operator_and_not:
            pr(" AND NOT ", client_data);
            break;
        case  Z_Operator_prox:
            solr_transform_set_error(ct, YAZ_BIB1_UNSUPP_SEARCH, 0);
            return -1;
        }
        r = rpn2solr_structure(ct, pr, client_data, q->u.complex->s2, 1, w);
        if (nested)
            pr(")", client_data);
        return r;
    }
}