static void emit_wordlist(cql_transform_t ct, struct cql_node *cn, void (*pr)(const char *buf, void *client_data), void *client_data, const char *op) { const char *cp0 = cn->u.st.term; const char *cp1; const char *last_term = 0; int last_length = 0; while(cp0) { while (*cp0 == ' ') cp0++; cp1 = strchr(cp0, ' '); if (last_term) { (*pr)("@", client_data); (*pr)(op, client_data); (*pr)(" ", client_data); emit_term(ct, cn, last_term, last_length, pr, client_data); } last_term = cp0; if (cp1) last_length = cp1 - cp0; else last_length = strlen(cp0); cp0 = cp1; } if (last_term) emit_term(ct, cn, last_term, last_length, pr, client_data); }
static void emit_terms(cql_transform_t ct, struct cql_node *cn, void (*pr)(const char *buf, void *client_data), void *client_data, const char *op) { struct cql_node *ne = cn->u.st.extra_terms; if (ne) { (*pr)("@", client_data); (*pr)(op, client_data); (*pr)(" ", client_data); } emit_term(ct, cn, cn->u.st.term, strlen(cn->u.st.term), pr, client_data); for (; ne; ne = ne->u.st.extra_terms) { if (ne->u.st.extra_terms) { (*pr)("@", client_data); (*pr)(op, client_data); (*pr)(" ", client_data); } emit_term(ct, cn, ne->u.st.term, strlen(ne->u.st.term), pr, client_data); } }
static int rpn2solr_simple(solr_transform_t ct, void (*pr)(const char *buf, void *client_data), void *client_data, Z_AttributesPlusTerm *apt, WRBUF w, Z_AttributesPlusTerm *apt2) { int ret = 0; Z_Term *term = apt->term; Odr_int trunc = get_truncation(apt); const char *relation2 = 0; const char *relation1 = solr_lookup_reverse(ct, "relation.", apt->attributes); /* Attempt to fix bug #2978: Look for a relation attribute */ if (!relation1) relation1 = lookup_relation_index_from_attr(apt->attributes); if (!relation1) { return YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE; } if (apt2) { relation2 = solr_lookup_reverse(ct, "relation.", apt2->attributes); if (!relation2) relation2 = lookup_relation_index_from_attr(apt2->attributes); } wrbuf_rewind(w); ret = rpn2solr_attr(ct, apt->attributes, w); if (ret) return ret; if ((trunc >= 0 && trunc <= 3) || trunc == 100 || trunc == 104) ; else { return YAZ_BIB1_UNSUPP_TRUNCATION_ATTRIBUTE; } if (!relation1) ret = emit_term(ct, w, term, trunc); else if (relation1[0] == '<' || relation1[0] == 'l') { wrbuf_puts(w, "[* TO "); ret = emit_term(ct, w, term, trunc); if (!strcmp(relation1, "le") || !strcmp(relation1, "<=")) wrbuf_puts(w, "]"); else wrbuf_puts(w, "}"); } else if (relation1[0] == '>' || relation1[0] == 'g') { if (!strcmp(relation1, ">=") || !strcmp(relation1, "ge")) wrbuf_puts(w, "["); else wrbuf_puts(w, "{"); ret = emit_term(ct, w, term, trunc); wrbuf_puts(w, " TO "); if (apt2) { emit_term(ct, w, apt2->term, 0); if (!relation2 || !strcmp(relation2, "<=") || !strcmp(relation2, "le")) wrbuf_puts(w, "]"); else wrbuf_puts(w, "}"); } else wrbuf_puts(w, "*]"); } else ret = emit_term(ct, w, term, trunc); if (ret == 0) pr(wrbuf_cstr(w), client_data); return ret; }