static int rpn2solr_attr(solr_transform_t ct, Z_AttributeList *attributes, WRBUF w) { const char *index = solr_lookup_reverse(ct, "index.", attributes); const char *structure = solr_lookup_reverse(ct, "structure.", attributes); /* if no real match, try string attribute */ if (!index) index = lookup_index_from_string_attr(attributes); if (!index) return YAZ_BIB1_UNSUPP_USE_ATTRIBUTE; /* for serverChoice we omit index+relation+structure */ if (strcmp(index, "cql.serverChoice")) { wrbuf_puts(w, index); wrbuf_puts(w, ":"); if (structure) { if (strcmp(structure, "*")) { wrbuf_puts(w, "/"); wrbuf_puts(w, structure); wrbuf_puts(w, " "); } } } return 0; }
static int check_range(solr_transform_t ct, Z_Complex *q, Z_AttributesPlusTerm **p_apt1, Z_AttributesPlusTerm **p_apt2) { Z_Operator *op = q->roperator; if (op->which == Z_Operator_and && q->s1->which == Z_RPNStructure_simple && q->s2->which == Z_RPNStructure_simple && q->s1->u.simple->which == Z_Operand_APT && q->s2->u.simple->which == Z_Operand_APT) { Z_AttributesPlusTerm *apt1 = q->s1->u.simple->u.attributesPlusTerm; Z_AttributesPlusTerm *apt2 = q->s2->u.simple->u.attributesPlusTerm; const char *i1 = solr_lookup_reverse(ct, "index.", apt1->attributes); const char *i2 = solr_lookup_reverse(ct, "index.", apt2->attributes); const char *rel1 = solr_lookup_reverse(ct, "relation.", apt1->attributes); const char *rel2 = solr_lookup_reverse(ct, "relation.", apt2->attributes); if (!rel1) rel1 = lookup_relation_index_from_attr(apt1->attributes); if (!rel2) rel2 = lookup_relation_index_from_attr(apt2->attributes); if (!i1) i1 = lookup_index_from_string_attr(apt1->attributes); if (!i2) i2 = lookup_index_from_string_attr(apt2->attributes); if (i1 && i2 && !strcmp(i1, i2) && rel1 && rel2) { if ((rel1[0] == '>' || rel1[0] == 'g') && (rel2[0] == '<' || rel2[0] == 'l')) { *p_apt1 = apt1; *p_apt2 = apt2; return 1; } if ((rel2[0] == '>' || rel2[0] == 'g') && (rel1[0] == '<' || rel1[0] == 'l')) { *p_apt1 = apt2; *p_apt2 = apt1; return 1; } } } return 0; }
static int rpn2cql_attr(cql_transform_t ct, Z_AttributeList *attributes, WRBUF w) { const char *relation = cql_lookup_reverse(ct, "relation.", attributes); const char *index = cql_lookup_reverse(ct, "index.", attributes); const char *structure = cql_lookup_reverse(ct, "structure.", attributes); /* if transform (properties) do not match, we'll just use a USE string attribute (bug #2978) */ if (!index) index = lookup_index_from_string_attr(attributes); /* Attempt to fix bug #2978: Look for a relation attribute */ if (!relation) relation = lookup_relation_index_from_attr(attributes); if (!index) { cql_transform_set_error(ct, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0); return -1; } /* for serverChoice we omit index+relation+structure */ if (strcmp(index, "cql.serverChoice")) { wrbuf_puts(w, index); if (relation) { if (!strcmp(relation, "exact")) relation = "=="; else if (!strcmp(relation, "eq")) relation = "="; else if (!strcmp(relation, "le")) relation = "<="; else if (!strcmp(relation, "ge")) relation = ">="; /* Missing mapping of not equal, phonetic, stem and relevance */ wrbuf_puts(w, relation); } else wrbuf_puts(w, "="); if (structure) { if (strcmp(structure, "*")) { wrbuf_puts(w, "/"); wrbuf_puts(w, structure); wrbuf_puts(w, " "); } } } return 0; }
static int rpn2solr_attr(solr_transform_t ct, Z_AttributeList *attributes, WRBUF w) { const char *relation = solr_lookup_reverse(ct, "relation.", attributes); const char *index = solr_lookup_reverse(ct, "index.", attributes); const char *structure = solr_lookup_reverse(ct, "structure.", attributes); /* if transform (properties) do not match, we'll just use a USE string attribute (bug #2978) */ if (!index) index = lookup_index_from_string_attr(attributes); /* Attempt to fix bug #2978: Look for a relation attribute */ if (!relation) relation = lookup_relation_index_from_attr(attributes); if (!index) { solr_transform_set_error(ct, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0); return -1; } /* for serverChoice we omit index+relation+structure */ if (strcmp(index, "solr.serverChoice")) { wrbuf_puts(w, index); if (relation) { if (!strcmp(relation, "exact")) /* TODO Verify if a exact SOLR exists */ relation = ":"; else if (!strcmp(relation, "eq")) relation = ":"; else if (!strcmp(relation, "le")) { /* TODO Not support as such, but could perhaps be transformed into a range relation = ":[ * to "; close_range = "]" */ } else if (!strcmp(relation, "ge")) { /* TODO Not support as such, but could perhaps be transformed into a range relation = "["; relation = ":[ * to "; close_range = "]" */ } /* Missing mapping of not equal, phonetic, stem and relevance */ wrbuf_puts(w, relation); } else wrbuf_puts(w, ":"); if (structure) { if (strcmp(structure, "*")) { wrbuf_puts(w, "/"); wrbuf_puts(w, structure); wrbuf_puts(w, " "); } } } return 0; }