33 #include <yaz/diagbib1.h>
34 #include <yaz/snprintf.h>
51 const char *outp = *out;
52 yaz_log(YLOG_LOG,
"---");
55 yaz_log(YLOG_LOG,
"%02X", *outp);
88 static int add_isam_p(
const char *name,
const char *info,
108 new_isam_p_buf = (
ISAM_P *) xmalloc(
sizeof(*new_isam_p_buf) *
119 new_term_no = (
int *) xmalloc(
sizeof(*new_term_no) * p->
isam_p_size);
137 const char *index_name;
141 yaz_log(
log_level_rpn,
"grep: %d %c %s", ord, name[len], term_tmp);
143 ord, 0 , &db, &index_name);
144 yaz_log(
log_level_rpn,
"grep: db=%s index=%s", db, index_name);
147 index_name, term_tmp);
159 const char *ct1,
int first)
161 const char *s1, *s0 = *src;
167 if (ct1 && strchr(ct1, *s0))
180 static void esc_str(
char *out_buf,
size_t out_size,
181 const char *in_buf,
int in_size)
187 assert(out_size > 20);
189 for (k = 0; k < in_size; k++)
191 int c = in_buf[k] & 0xff;
193 if (c < 32 || c > 126)
197 yaz_snprintf(out_buf + strlen(out_buf), 20,
"%02X:%c ", c, pc);
198 if (strlen(out_buf) > out_size-20)
200 strcat(out_buf,
"..");
206 #define REGEX_CHARS " ^[]()|.*+?!\"$\\"
211 const char **map,
int q_map_match)
213 size_t sz =
end - start;
215 wrbuf_write(display_term, start, sz);
221 wrbuf_putc(term_dict,
'\\');
222 wrbuf_putc(term_dict, *start);
229 esc_str(tmpbuf,
sizeof(tmpbuf), map[0], strlen(map[0]));
231 wrbuf_puts(term_dict, map[0]);
243 while (i > 0 && buf[--i] !=
'\x01')
245 while (i > 0 && buf[--i] !=
'\x01')
251 const char **src, WRBUF term_dict,
int space_split,
255 const char *s0 = *src, *s1;
261 if (*s1 ==
' ' && space_split)
270 const char *res_buf = 0;
272 const char *display_buf;
278 &display_buf, &display_len))
282 for (i = 0; i < res_len; i++)
285 wrbuf_putc(term_dict,
'\\');
287 wrbuf_putc(term_dict,
'\x01');
289 wrbuf_putc(term_dict, res_buf[i]);
291 wrbuf_write(display_term, display_buf, display_len);
299 wrbuf_putc(term_dict, *s1);
300 wrbuf_putc(display_term, *s1);
307 wrbuf_puts(term_dict,
"\x01\x01.*");
313 const char **src, WRBUF term_dict,
319 const char *res_buf = 0;
321 const char *display_buf;
325 for (i = 0; i <= token_number; i++)
328 &display_buf, &display_len))
331 wrbuf_write(display_term, display_buf, display_len);
337 wrbuf_puts(term_dict,
".*");
338 for (i = 0; i < res_len; i++)
341 wrbuf_putc(term_dict,
'\\');
343 wrbuf_putc(term_dict,
'\x01');
345 wrbuf_putc(term_dict, res_buf[i]);
348 wrbuf_puts(term_dict,
".*");
350 wrbuf_puts(term_dict,
"\x01\x01.*");
356 const char **src, WRBUF term_dict,
int space_split,
363 const char *space_start = 0;
364 const char *space_end = 0;
366 if (!
term_pre(zm, src, 0, !space_split))
387 else if (space_start)
389 while (space_start < space_end)
392 wrbuf_putc(term_dict,
'\\');
393 wrbuf_putc(display_term, *space_start);
394 wrbuf_putc(term_dict, *space_start);
399 space_start = space_end = 0;
404 add_non_space(s1, s0, term_dict, display_term, map, q_map_match);
412 const char **src, WRBUF term_dict,
int space_split,
419 if (!
term_pre(zm, src,
"#", !space_split))
427 wrbuf_puts(term_dict,
".*");
428 wrbuf_putc(display_term, *s0);
440 add_non_space(s1, s0, term_dict, display_term, map, q_map_match);
449 WRBUF term_dict,
int *errors,
int space_split,
456 if (!
term_pre(zm, src,
"^\\()[].*+?|", !space_split))
459 if (errors && *s0 ==
'+' && s0[1] && s0[2] ==
'+' && s0[3] &&
460 isdigit(((
const unsigned char *)s0)[1]))
462 *errors = s0[1] -
'0';
469 if (strchr(
"^\\()[].*+?|-", *s0))
471 wrbuf_putc(display_term, *s0);
472 wrbuf_putc(term_dict, *s0);
485 add_non_space(s1, s0, term_dict, display_term, map, q_map_match);
495 WRBUF term_dict,
int space_split, WRBUF display_term)
497 return term_103(zm, src, term_dict, NULL, space_split, display_term);
503 WRBUF term_dict,
int space_split, WRBUF display_term)
509 if (!
term_pre(zm, src,
"?*#", !space_split))
517 wrbuf_putc(display_term, *s0);
519 if (*s0 >=
'0' && *s0 <=
'9')
522 while (*s0 >=
'0' && *s0 <=
'9')
524 limit = limit * 10 + (*s0 -
'0');
525 wrbuf_putc(display_term, *s0);
532 wrbuf_puts(term_dict,
".?");
537 wrbuf_puts(term_dict,
".*");
543 wrbuf_puts(term_dict,
".*");
544 wrbuf_putc(display_term, *s0);
550 wrbuf_puts(term_dict,
".");
551 wrbuf_putc(display_term, *s0);
563 add_non_space(s1, s0, term_dict, display_term, map, q_map_match);
572 WRBUF term_dict,
int space_split,
573 WRBUF display_term,
int right_truncate)
579 if (!
term_pre(zm, src,
"\\*!", !space_split))
587 wrbuf_puts(term_dict,
".*");
588 wrbuf_putc(display_term, *s0);
594 wrbuf_putc(term_dict,
'.');
595 wrbuf_putc(display_term, *s0);
598 else if (*s0 ==
'\\')
601 wrbuf_puts(term_dict,
"\\\\");
602 wrbuf_putc(display_term, *s0);
614 add_non_space(s1, s0, term_dict, display_term, map, q_map_match);
618 wrbuf_puts(term_dict,
".*");
634 yaz_log(YLOG_DEBUG,
"gen_regular_rel. val=%d, islt=%d", val, islt);
638 wrbuf_puts(dst,
"(-[0-9]+|(");
640 wrbuf_puts(dst,
"((");
646 wrbuf_puts(dst,
"([0-9]+|-(");
651 wrbuf_puts(dst,
"(-(");
656 yaz_snprintf(numstr,
sizeof(numstr),
"%d", val);
657 for (w = strlen(numstr); --w >= 0; pos++)
675 wrbuf_write(dst, numstr, w);
680 wrbuf_putc(dst,
'[');
681 wrbuf_putc(dst,
'0');
682 wrbuf_putc(dst,
'-');
684 wrbuf_putc(dst,
']');
693 wrbuf_putc(dst,
'[');
695 wrbuf_putc(dst,
'-');
696 wrbuf_putc(dst,
'9');
697 wrbuf_putc(dst,
']');
702 for (i = 0; i < pos; i++)
703 wrbuf_puts(dst,
"[0-9]");
704 wrbuf_putc(dst,
'|');
709 wrbuf_puts(dst,
"0*");
710 for (i = 1; i < pos; i++)
711 wrbuf_puts(dst,
"[0-9]?");
716 for (i = 0; i <= pos; i++)
717 wrbuf_puts(dst,
"[0-9]");
718 wrbuf_puts(dst,
"[0-9]*");
720 wrbuf_puts(dst,
"))");
725 const char *src = wrbuf_cstr(wsrc);
726 if (src[*indx] ==
'\\')
728 wrbuf_putc(term_p, src[*indx]);
731 wrbuf_putc(term_p, src[*indx]);
746 const char **term_sub, WRBUF term_dict,
747 const Odr_oid *attributeSet,
755 WRBUF term_component = wrbuf_alloc();
758 relation_value =
attr_find(&relation, NULL);
761 yaz_log(YLOG_DEBUG,
"string relation value=%d", relation_value);
762 switch (relation_value)
765 if (!
term_100(zm, term_sub, term_component, space_split, display_term))
767 wrbuf_destroy(term_component);
772 wrbuf_putc(term_dict,
'(');
773 for (i = 0; i < wrbuf_len(term_component); )
778 wrbuf_putc(term_dict,
'|');
782 wrbuf_putc(term_dict,
'[');
784 wrbuf_putc(term_dict,
'^');
786 wrbuf_putc(term_dict, 1);
790 wrbuf_putc(term_dict,
'-');
792 wrbuf_putc(term_dict,
']');
793 wrbuf_putc(term_dict,
'.');
794 wrbuf_putc(term_dict,
'*');
796 wrbuf_putc(term_dict,
')');
799 if (!
term_100(zm, term_sub, term_component, space_split, display_term))
801 wrbuf_destroy(term_component);
806 wrbuf_putc(term_dict,
'(');
807 for (i = 0; i < wrbuf_len(term_component); )
813 wrbuf_putc(term_dict,
'[');
815 wrbuf_putc(term_dict,
'^');
817 wrbuf_putc(term_dict, 1);
821 wrbuf_putc(term_dict,
'-');
823 wrbuf_putc(term_dict,
']');
824 wrbuf_putc(term_dict,
'.');
825 wrbuf_putc(term_dict,
'*');
827 wrbuf_putc(term_dict,
'|');
829 for (i = 0; i < wrbuf_len(term_component); )
831 wrbuf_putc(term_dict,
')');
834 if (!
term_100(zm, term_sub, term_component, space_split, display_term))
836 wrbuf_destroy(term_component);
841 wrbuf_putc(term_dict,
'(');
842 for (i = 0; i < wrbuf_len(term_component); )
848 wrbuf_putc(term_dict,
'[');
850 wrbuf_putc(term_dict,
'^');
851 wrbuf_putc(term_dict,
'-');
854 wrbuf_putc(term_dict,
']');
855 wrbuf_putc(term_dict,
'.');
856 wrbuf_putc(term_dict,
'*');
858 wrbuf_putc(term_dict,
'|');
860 for (i = 0; i < wrbuf_len(term_component); )
862 wrbuf_putc(term_dict,
'.');
863 wrbuf_putc(term_dict,
'+');
864 wrbuf_putc(term_dict,
')');
867 if (!
term_100(zm, term_sub, term_component, space_split, display_term))
869 wrbuf_destroy(term_component);
874 wrbuf_putc(term_dict,
'(');
875 for (i = 0; i < wrbuf_len(term_component); )
880 wrbuf_putc(term_dict,
'|');
883 wrbuf_putc(term_dict,
'[');
885 if (i < wrbuf_len(term_component)-1)
887 wrbuf_putc(term_dict,
'^');
888 wrbuf_putc(term_dict,
'-');
894 wrbuf_putc(term_dict,
'-');
896 wrbuf_putc(term_dict,
']');
897 wrbuf_putc(term_dict,
'.');
898 wrbuf_putc(term_dict,
'*');
900 wrbuf_putc(term_dict,
')');
908 if (!
term_100(zm, term_sub, term_component, space_split, display_term))
910 wrbuf_destroy(term_component);
913 wrbuf_puts(term_dict,
"(");
914 wrbuf_puts(term_dict, wrbuf_cstr(term_component));
915 wrbuf_puts(term_dict,
")");
920 while (**term_sub !=
'\0')
924 *error_code = YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE;
925 wrbuf_destroy(term_component);
928 wrbuf_destroy(term_component);
933 const char **term_sub,
935 const Odr_oid *attributeSet, NMEM stream,
937 const char *index_type,
int complete_flag,
939 const char *xpath_use,
944 Z_AttributesPlusTerm *zapt,
945 zint *hits_limit_value,
946 const char **term_ref_id_str,
952 zint hits_limit_from_attr;
955 hits_limit_from_attr =
attr_find(&hits_limit_attr, NULL);
958 term_ref_id_int =
attr_find_ex(&term_ref_id_attr, NULL, term_ref_id_str);
959 if (term_ref_id_int >= 0)
961 char *res = nmem_malloc(nmem, 20);
962 yaz_snprintf(res, 20,
"%d", term_ref_id_int);
963 *term_ref_id_str = res;
965 if (hits_limit_from_attr != -1)
966 *hits_limit_value = hits_limit_from_attr;
968 yaz_log(YLOG_DEBUG,
"term_limits_APT ref_id=%s limit=" ZINT_FORMAT,
969 *term_ref_id_str ? *term_ref_id_str :
"none",
977 Z_AttributesPlusTerm *zapt,
978 const char **term_sub,
979 const Odr_oid *attributeSet,
980 zint hits_limit, NMEM stream,
982 const char *index_type,
int complete_flag,
983 const char *rank_type,
984 const char *xpath_use,
993 zint hits_limit_value = hits_limit;
994 const char *term_ref_id_str = 0;
995 WRBUF term_dict = wrbuf_alloc();
996 WRBUF display_term = wrbuf_alloc();
1003 index_type, complete_flag,
1004 display_term, xpath_use, &ol, zm, token_number);
1005 wrbuf_destroy(term_dict);
1008 yaz_log(
log_level_rpn,
"term: %s", wrbuf_cstr(display_term));
1011 wrbuf_len(display_term), rank_type,
1013 zapt->term->which, rset_nmem,
1014 kc, kc->
scope, ol, index_type, hits_limit_value,
1019 wrbuf_destroy(display_term);
1024 const char **term_sub,
1026 const Odr_oid *attributeSet, NMEM stream,
1028 const char *index_type,
int complete_flag,
1030 const char *xpath_use,
1036 int truncation_value;
1040 int space_split = complete_flag ? 0 : 1;
1042 int regex_range = 0;
1043 int max_pos, prefix_len = 0;
1052 truncation_value =
attr_find(&truncation, NULL);
1053 yaz_log(
log_level_rpn,
"truncation value %d", truncation_value);
1064 wrbuf_rewind(term_dict);
1069 wrbuf_putc(term_dict,
'(');
1071 for (i = 0; i < ord_len; i++)
1073 wrbuf_putc(term_dict, 1);
1074 wrbuf_putc(term_dict, ord_buf[i]);
1076 wrbuf_putc(term_dict,
')');
1078 prefix_len = wrbuf_len(term_dict);
1086 relation_value =
attr_find(&relation, NULL);
1087 if (relation_value == 103)
1088 termp += strlen(termp);
1089 else if (relation_value == 3 || relation_value == 102 || relation_value == -1)
1092 switch (truncation_value)
1096 if (!
term_100_icu(
zm, &termp, term_dict, display_term, 0, token_number))
1103 if (!
term_102_icu(
zm, &termp, term_dict, space_split, display_term))
1110 if (!
term_100_icu(
zm, &termp, term_dict, display_term, 1, token_number))
1117 if (!
term_100_icu(
zm, &termp, term_dict, display_term, 2, token_number))
1124 if (!
term_100_icu(
zm, &termp, term_dict, display_term, 3, token_number))
1132 YAZ_BIB1_UNSUPP_TRUNCATION_ATTRIBUTE,
1140 YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE,
1148 switch (truncation_value)
1154 zm, space_split, display_term,
1167 wrbuf_putc(term_dict,
'(');
1168 if (!
term_100(
zm, &termp, term_dict, space_split, display_term))
1173 wrbuf_puts(term_dict,
".*)");
1176 wrbuf_puts(term_dict,
"(.*");
1177 if (!
term_100(
zm, &termp, term_dict, space_split, display_term))
1182 wrbuf_putc(term_dict,
')');
1185 wrbuf_puts(term_dict,
"(.*");
1186 if (!
term_100(
zm, &termp, term_dict, space_split, display_term))
1191 wrbuf_puts(term_dict,
".*)");
1194 wrbuf_putc(term_dict,
'(');
1195 if (!
term_101(
zm, &termp, term_dict, space_split, display_term))
1200 wrbuf_puts(term_dict,
")");
1203 wrbuf_putc(term_dict,
'(');
1204 if (!
term_102(
zm, &termp, term_dict, space_split, display_term))
1209 wrbuf_putc(term_dict,
')');
1213 wrbuf_putc(term_dict,
'(');
1214 if (!
term_103(
zm, &termp, term_dict, ®ex_range,
1215 space_split, display_term))
1220 wrbuf_putc(term_dict,
')');
1223 wrbuf_putc(term_dict,
'(');
1224 if (!
term_104(
zm, &termp, term_dict, space_split, display_term))
1229 wrbuf_putc(term_dict,
')');
1232 wrbuf_putc(term_dict,
'(');
1233 if (!
term_105(
zm, &termp, term_dict, space_split, display_term, 1))
1238 wrbuf_putc(term_dict,
')');
1241 wrbuf_putc(term_dict,
'(');
1242 if (!
term_105(
zm, &termp, term_dict, space_split, display_term, 0))
1247 wrbuf_putc(term_dict,
')');
1251 YAZ_BIB1_UNSUPP_TRUNCATION_ATTRIBUTE,
1259 const char *input = wrbuf_cstr(term_dict) + prefix_len;
1260 esc_str(buf,
sizeof(buf), input, strlen(input));
1263 WRBUF pr_wr = wrbuf_alloc();
1265 wrbuf_write_escaped(pr_wr, wrbuf_buf(term_dict), wrbuf_len(term_dict));
1266 yaz_log(YLOG_LOG,
"dict_lookup_grep: %s", wrbuf_cstr(pr_wr));
1267 wrbuf_destroy(pr_wr);
1276 yaz_log(YLOG_WARN,
"dict_lookup_grep fail %d", r);
1293 Z_AttributesPlusTerm *zapt,
1295 const char *index_type)
1312 truncmax_value =
attr_find(&truncmax, NULL);
1313 if (truncmax_value != -1)
1319 int termset_value_numeric;
1320 const char *termset_value_string;
1323 termset_value_numeric =
1325 if (termset_value_numeric != -1)
1335 Z_AttributesPlusTerm *zapt,
1337 const Odr_oid *attributeSet,
1340 const char *index_type,
int complete_flag,
1341 const char *rank_type,
1342 const char *xpath_use,
1344 RSET **result_sets,
int *num_result_sets,
1349 const char *termp = termz;
1352 *num_result_sets = 0;
1359 if (alloc_sets == *num_result_sets)
1362 RSET *rnew = (
RSET *) nmem_malloc(stream, (alloc_sets+
add) *
1365 memcpy(rnew, *result_sets, alloc_sets *
sizeof(*rnew));
1366 alloc_sets = alloc_sets +
add;
1367 *result_sets = rnew;
1369 res =
search_term(
zh, zapt, &termp, attributeSet, hits_limit,
1373 xpath_use, rset_nmem,
1374 &(*result_sets)[*num_result_sets],
1380 for (i = 0; i < *num_result_sets; i++)
1385 if ((*result_sets)[*num_result_sets] == 0)
1387 (*num_result_sets)++;
1413 Z_AttributesPlusTerm *zapt,
1415 const Odr_oid *attributeSet,
1419 const char *rank_type,
1420 const char *xpath_use,
1422 RSET **result_sets,
int *num_result_sets,
1428 rank_type, xpath_use,
1429 rset_nmem, result_sets, num_result_sets,
1440 WRBUF w = wrbuf_alloc();
1442 wrbuf_puts(w, unit);
1450 char term_dict[100];
1451 memcpy(term_dict, ord_buf, ord_len);
1452 strcpy(term_dict + ord_len, term);
1457 assert(*val ==
sizeof(
ISAM_P));
1458 memcpy(&isam_p, val+1,
sizeof(isam_p));
1466 Z_AttributesPlusTerm *zapt,
1467 const Odr_oid *attributeSet,
1477 char term_dict[100];
1484 position_value =
attr_find(&position, NULL);
1485 switch(position_value)
1513 memcpy(term_dict, ord_buf, ord_len);
1518 assert(*val ==
sizeof(
ISAM_P));
1519 memcpy(&isam_p, val+1,
sizeof(isam_p));
1530 Z_AttributesPlusTerm *zapt,
1531 const char *termz_org,
1532 const Odr_oid *attributeSet,
1537 const char *rank_type,
1538 const char *xpath_use,
1543 RSET *result_sets = 0;
1544 int num_result_sets = 0;
1548 rank_type, xpath_use,
1550 &result_sets, &num_result_sets, kc);
1555 if (num_result_sets > 0)
1560 rset_nmem, &first_set,
1565 for (i = 0; i < num_result_sets; i++)
1571 RSET *nsets = nmem_malloc(stream,
1572 sizeof(
RSET) * (num_result_sets+1));
1573 nsets[0] = first_set;
1574 memcpy(nsets+1, result_sets,
sizeof(
RSET) * num_result_sets);
1575 result_sets = nsets;
1579 if (num_result_sets == 0)
1581 else if (num_result_sets == 1)
1582 *
rset = result_sets[0];
1585 num_result_sets, result_sets,
1596 Z_AttributesPlusTerm *zapt,
1597 const char *termz_org,
1598 const Odr_oid *attributeSet,
1603 const char *rank_type,
1604 const char *xpath_use,
1609 RSET *result_sets = 0;
1610 int num_result_sets = 0;
1615 rank_type, xpath_use,
1617 &result_sets, &num_result_sets, kc);
1621 for (i = 0; i < num_result_sets; i++)
1626 rset_nmem, &first_set,
1630 for (i = 0; i < num_result_sets; i++)
1639 tmp_set[0] = first_set;
1640 tmp_set[1] = result_sets[i];
1643 rset_nmem, kc, kc->
scope,
1649 if (num_result_sets == 0)
1651 else if (num_result_sets == 1)
1652 *
rset = result_sets[0];
1655 num_result_sets, result_sets);
1664 Z_AttributesPlusTerm *zapt,
1665 const char *termz_org,
1666 const Odr_oid *attributeSet,
1671 const char *rank_type,
1672 const char *xpath_use,
1677 RSET *result_sets = 0;
1678 int num_result_sets = 0;
1683 rank_type, xpath_use,
1685 &result_sets, &num_result_sets,
1689 for (i = 0; i < num_result_sets; i++)
1694 rset_nmem, &first_set,
1698 for (i = 0; i < num_result_sets; i++)
1707 tmp_set[0] = first_set;
1708 tmp_set[1] = result_sets[i];
1711 rset_nmem, kc, kc->
scope,
1719 if (num_result_sets == 0)
1721 else if (num_result_sets == 1)
1722 *
rset = result_sets[0];
1725 num_result_sets, result_sets);
1732 const char **term_sub,
1734 const Odr_oid *attributeSet,
1745 WRBUF term_num = wrbuf_alloc();
1749 relation_value =
attr_find(&relation, NULL);
1751 yaz_log(
log_level_rpn,
"numeric relation value=%d", relation_value);
1753 switch (relation_value)
1757 if (!
term_100(zm, term_sub, term_num, 1, display_term))
1759 wrbuf_destroy(term_num);
1762 term_value = atoi(wrbuf_cstr(term_num));
1767 if (!
term_100(zm, term_sub, term_num, 1, display_term))
1769 wrbuf_destroy(term_num);
1772 term_value = atoi(wrbuf_cstr(term_num));
1777 if (!
term_100(zm, term_sub, term_num, 1, display_term))
1779 wrbuf_destroy(term_num);
1782 term_value = atoi(wrbuf_cstr(term_num));
1787 if (!
term_100(zm, term_sub, term_num, 1, display_term))
1789 wrbuf_destroy(term_num);
1792 term_value = atoi(wrbuf_cstr(term_num));
1799 if (!
term_100(zm, term_sub, term_num, 1, display_term))
1801 wrbuf_destroy(term_num);
1804 term_value = atoi(wrbuf_cstr(term_num));
1805 wrbuf_printf(term_dict,
"(0*%d)", term_value);
1809 while (**term_sub !=
'\0')
1813 *error_code = YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE;
1814 wrbuf_destroy(term_num);
1823 yaz_log(YLOG_WARN,
"dict_lookup_grep fail, rel = gt: %d", r);
1825 wrbuf_destroy(term_num);
1830 const char **term_sub,
1832 const Odr_oid *attributeSet, NMEM stream,
1836 const char *xpath_use,
1842 int relation_error = 0;
1843 int ord, ord_len, i;
1859 wrbuf_rewind(term_dict);
1865 wrbuf_putc(term_dict,
'(');
1866 for (i = 0; i < ord_len; i++)
1868 wrbuf_putc(term_dict, 1);
1869 wrbuf_putc(term_dict, ord_buf[i]);
1871 wrbuf_putc(term_dict,
')');
1875 display_term, &relation_error))
1892 Z_AttributesPlusTerm *zapt,
1894 const Odr_oid *attributeSet,
1897 const char *index_type,
1899 const char *rank_type,
1900 const char *xpath_use,
1905 const char *termp = termz;
1906 RSET *result_sets = 0;
1907 int num_result_sets = 0;
1911 zint hits_limit_value = hits_limit;
1912 const char *term_ref_id_str = 0;
1923 WRBUF term_dict = wrbuf_alloc();
1924 WRBUF display_term = wrbuf_alloc();
1925 if (alloc_sets == num_result_sets)
1928 RSET *rnew = (
RSET *) nmem_malloc(stream, (alloc_sets+
add) *
1931 memcpy(rnew, result_sets, alloc_sets *
sizeof(*rnew));
1932 alloc_sets = alloc_sets +
add;
1935 yaz_log(YLOG_DEBUG,
"APT_numeric termp=%s", termp);
1939 index_type, complete_flag,
1940 display_term, xpath_use, &ol);
1941 wrbuf_destroy(term_dict);
1944 wrbuf_destroy(display_term);
1947 yaz_log(YLOG_DEBUG,
"term: %s", wrbuf_cstr(display_term));
1948 result_sets[num_result_sets] =
1951 wrbuf_len(display_term), rank_type,
1953 zapt->term->which, rset_nmem,
1954 kc, kc->
scope, ol, index_type,
1957 wrbuf_destroy(display_term);
1958 if (!result_sets[num_result_sets])
1968 if (num_result_sets == 0)
1970 else if (num_result_sets == 1)
1971 *
rset = result_sets[0];
1974 num_result_sets, result_sets);
1981 Z_AttributesPlusTerm *zapt,
1983 const Odr_oid *attributeSet,
1985 const char *rank_type, NMEM rset_nmem,
2022 const Odr_oid *attributeSet, NMEM stream,
2023 Z_SortKeySpecList *sort_sequence,
2024 const char *rank_type,
2030 int sort_relation_value;
2037 sort_relation_value =
attr_find(&sort_relation_type, &attributeSet);
2039 if (!sort_sequence->specs)
2041 sort_sequence->num_specs = 10;
2042 sort_sequence->specs = (Z_SortKeySpec **)
2043 nmem_malloc(stream, sort_sequence->num_specs *
2044 sizeof(*sort_sequence->specs));
2045 for (i = 0; i < sort_sequence->num_specs; i++)
2046 sort_sequence->specs[i] = 0;
2048 if (zapt->term->which != Z_Term_general)
2051 i = atoi_n((
char *) zapt->term->u.general->buf,
2052 zapt->term->u.general->len);
2053 if (i >= sort_sequence->num_specs)
2055 yaz_snprintf(termz,
sizeof(termz),
"%d", i);
2057 sks = (Z_SortKeySpec *) nmem_malloc(stream,
sizeof(*sks));
2058 sks->sortElement = (Z_SortElement *)
2059 nmem_malloc(stream,
sizeof(*sks->sortElement));
2060 sks->sortElement->which = Z_SortElement_generic;
2061 sk = sks->sortElement->u.generic = (Z_SortKey *)
2062 nmem_malloc(stream,
sizeof(*sk));
2063 sk->which = Z_SortKey_sortAttributes;
2064 sk->u.sortAttributes = (Z_SortAttributes *)
2065 nmem_malloc(stream,
sizeof(*sk->u.sortAttributes));
2067 sk->u.sortAttributes->id = odr_oiddup_nmem(stream, attributeSet);
2068 sk->u.sortAttributes->list = zapt->attributes;
2070 sks->sortRelation = (Odr_int *)
2071 nmem_malloc(stream,
sizeof(*sks->sortRelation));
2072 if (sort_relation_value == 1)
2073 *sks->sortRelation = Z_SortKeySpec_ascending;
2074 else if (sort_relation_value == 2)
2075 *sks->sortRelation = Z_SortKeySpec_descending;
2077 *sks->sortRelation = Z_SortKeySpec_ascending;
2079 sks->caseSensitivity = (Odr_int *)
2080 nmem_malloc(stream,
sizeof(*sks->caseSensitivity));
2081 *sks->caseSensitivity = 0;
2083 sks->which = Z_SortKeySpec_null;
2084 sks->u.null = odr_nullval ();
2085 sort_sequence->specs[i] = sks;
2092 const Odr_oid *attributeSet,
2096 const Odr_oid *curAttributeSet = attributeSet;
2098 const char *use_string = 0;
2103 if (!use_string || *use_string !=
'/')
2112 const char *index_type,
const char *term,
2113 const char *xpath_use,
2131 WRBUF term_dict = wrbuf_alloc();
2133 int term_type = Z_Term_characterString;
2134 const char *flags =
"void";
2136 wrbuf_putc(term_dict,
'(');
2137 for (i = 0; i < ord_len; i++)
2139 wrbuf_putc(term_dict, 1);
2140 wrbuf_putc(term_dict, ord_buf[i]);
2142 wrbuf_putc(term_dict,
')');
2143 wrbuf_puts(term_dict, term);
2148 yaz_log(YLOG_DEBUG,
"%s %d positions", term,
2152 flags, 1, term_type, rset_nmem,
2156 wrbuf_destroy(term_dict);
2163 NMEM stream,
const char *rank_type,
RSET rset,
2170 int always_matches =
rset ? 0 : 1;
2178 yaz_log(YLOG_DEBUG,
"xpath len=%d", xpath_len);
2179 for (i = 0; i < xpath_len; i++)
2207 int level = xpath_len;
2210 while (--level >= 0)
2212 WRBUF xpath_rev = wrbuf_alloc();
2214 RSET rset_start_tag = 0, rset_end_tag = 0, rset_attr = 0;
2216 for (i = level; i >= 1; --i)
2218 const char *cp = xpath[i].
part;
2224 wrbuf_puts(xpath_rev,
"[^/]*");
2225 else if (*cp ==
' ')
2226 wrbuf_puts(xpath_rev,
"\001 ");
2228 wrbuf_putc(xpath_rev, *cp);
2234 wrbuf_puts(xpath_rev,
"/");
2237 wrbuf_puts(xpath_rev,
".*");
2239 if (xpath[level].predicate &&
2243 WRBUF wbuf = wrbuf_alloc();
2244 wrbuf_puts(wbuf, xpath[level].predicate->u.relation.name+1);
2245 if (xpath[level].predicate->u.relation.value)
2248 wrbuf_putc(wbuf,
'=');
2253 wrbuf_putc(wbuf,
'\\');
2254 wrbuf_putc(wbuf, *cp);
2259 zh, stream,
"0", wrbuf_cstr(wbuf),
2262 wrbuf_destroy(wbuf);
2268 wrbuf_destroy(xpath_rev);
2273 wrbuf_cstr(xpath_rev));
2274 if (wrbuf_len(xpath_rev))
2277 wrbuf_cstr(xpath_rev),
2281 rset = rset_start_tag;
2285 wrbuf_cstr(xpath_rev),
2290 rset_start_tag,
rset, NULL,
2291 rset_end_tag, rset_attr);
2294 wrbuf_destroy(xpath_rev);
2302 #define MAX_XPATH_STEPS 10
2305 Z_AttributesPlusTerm *zapt,
2306 const Odr_oid *attributeSet,
2307 zint hits_limit, NMEM stream,
2308 Z_SortKeySpecList *sort_sequence,
2314 const Odr_oid *attributeSet,
2315 zint hits_limit, NMEM stream,
2316 Z_SortKeySpecList *sort_sequence,
2317 int num_bases,
const char **basenames,
2322 RSET *rsets = nmem_malloc(stream, num_bases *
sizeof(*rsets));
2325 for (i = 0; i < num_bases; i++)
2337 rset_nmem, rsets+i, kc);
2351 else if (num_bases == 0)
2361 Z_AttributesPlusTerm *zapt,
2362 const Odr_oid *attributeSet,
2363 zint hits_limit, NMEM stream,
2364 Z_SortKeySpecList *sort_sequence,
2371 char *search_type = NULL;
2372 char rank_type[128];
2377 const char *xpath_use = 0;
2386 rank_type, &complete_flag, &sort_flag);
2388 yaz_log(YLOG_DEBUG,
"index_type=%s", index_type);
2389 yaz_log(YLOG_DEBUG,
"complete_flag=%d", complete_flag);
2390 yaz_log(YLOG_DEBUG,
"search_type=%s", search_type);
2391 yaz_log(YLOG_DEBUG,
"rank_type=%s", rank_type);
2397 return rpn_sort_spec(zh, zapt, attributeSet, stream, sort_sequence,
2398 rank_type, rset_nmem,
rset, kc);
2404 if (xpath[xpath_len-1].
part[0] ==
'@')
2415 relation_value =
attr_find(&relation, NULL);
2417 if (relation_value == 103)
2421 xpath_len, xpath, rset_nmem,
rset, kc);
2434 if (!strcmp(search_type,
"phrase"))
2438 index_type, complete_flag, rank_type,
2443 else if (!strcmp(search_type,
"and-list"))
2447 index_type, complete_flag, rank_type,
2452 else if (!strcmp(search_type,
"or-list"))
2456 index_type, complete_flag, rank_type,
2461 else if (!strcmp(search_type,
"local"))
2464 rank_type, rset_nmem,
rset, kc);
2466 else if (!strcmp(search_type,
"numeric"))
2470 index_type, complete_flag, rank_type,
2485 xpath_len, xpath, rset_nmem,
rset, kc);
2489 const Odr_oid *attributeSet,
2491 NMEM stream, NMEM rset_nmem,
2492 Z_SortKeySpecList *sort_sequence,
2493 int num_bases,
const char **basenames,
2494 RSET **result_sets,
int *num_result_sets,
2495 Z_Operator *parent_op,
2502 if (zs->which == Z_RPNStructure_complex)
2511 else if (zs->which == Z_RPNStructure_simple)
2513 if (zs->u.simple->which == Z_Operand_APT)
2515 Z_AttributesPlusTerm *zapt = zs->u.simple->u.attributesPlusTerm;
2521 l =
attr_find(&global_hits_limit_attr, NULL);
2530 const Odr_oid *attributeSet,
2532 NMEM stream, NMEM rset_nmem,
2533 Z_SortKeySpecList *sort_sequence,
2534 int num_bases,
const char **basenames,
2537 RSET *result_sets = 0;
2538 int num_result_sets = 0;
2545 num_bases, basenames,
2546 &result_sets, &num_result_sets,
2552 for (i = 0; i < num_result_sets; i++)
2558 assert(num_result_sets == 1);
2559 assert(result_sets);
2560 assert(*result_sets);
2561 *result_set = *result_sets;
2568 const Odr_oid *attributeSet,
zint hits_limit,
2569 NMEM stream, NMEM rset_nmem,
2570 Z_SortKeySpecList *sort_sequence,
2571 int num_bases,
const char **basenames,
2572 RSET **result_sets,
int *num_result_sets,
2573 Z_Operator *parent_op,
2576 *num_result_sets = 0;
2577 if (zs->which == Z_RPNStructure_complex)
2580 Z_Operator *zop = zs->u.complex->roperator;
2581 RSET *result_sets_l = 0;
2582 int num_result_sets_l = 0;
2583 RSET *result_sets_r = 0;
2584 int num_result_sets_r = 0;
2587 attributeSet, hits_limit, stream, rset_nmem,
2589 num_bases, basenames,
2590 &result_sets_l, &num_result_sets_l,
2595 for (i = 0; i < num_result_sets_l; i++)
2600 attributeSet, hits_limit, stream, rset_nmem,
2602 num_bases, basenames,
2603 &result_sets_r, &num_result_sets_r,
2608 for (i = 0; i < num_result_sets_l; i++)
2610 for (i = 0; i < num_result_sets_r; i++)
2616 *num_result_sets = num_result_sets_l + num_result_sets_r;
2617 *result_sets = nmem_malloc(stream, *num_result_sets *
2618 sizeof(**result_sets));
2619 memcpy(*result_sets, result_sets_l,
2620 num_result_sets_l *
sizeof(**result_sets));
2621 memcpy(*result_sets + num_result_sets_l, result_sets_r,
2622 num_result_sets_r *
sizeof(**result_sets));
2624 if (!parent_op || parent_op->which != zop->which
2625 || (zop->which != Z_Operator_and &&
2626 zop->which != Z_Operator_or))
2633 case Z_Operator_and:
2636 *num_result_sets, *result_sets);
2641 *num_result_sets, *result_sets);
2643 case Z_Operator_and_not:
2649 case Z_Operator_prox:
2650 if (zop->u.prox->which != Z_ProximityOperator_known)
2653 YAZ_BIB1_UNSUPP_PROX_UNIT_CODE,
2657 if (*zop->u.prox->u.known == Z_ProxUnit_word)
2661 *num_result_sets, *result_sets,
2662 *zop->u.prox->ordered,
2663 (!zop->u.prox->exclusion ?
2664 0 : *zop->u.prox->exclusion),
2665 *zop->u.prox->relationType,
2666 *zop->u.prox->distance );
2668 else if (*zop->u.prox->u.known >= 3 &&
2669 *zop->u.prox->u.known <= 10 &&
2670 *num_result_sets == 2)
2673 static const char *units[] = {
2683 const char *unit = units[*zop->u.prox->u.known - 3];
2688 if (begin_set && end_set)
2691 rset_nmem, kc, kc->
scope,
2693 (*result_sets[0]), (*result_sets)[1], end_set,
2703 YAZ_BIB1_UNSUPP_PROX_UNIT_CODE,
2704 *zop->u.prox->u.known);
2712 YAZ_BIB1_UNSUPP_PROX_UNIT_CODE,
2713 *zop->u.prox->u.known);
2721 *num_result_sets = 1;
2722 *result_sets = nmem_malloc(stream, *num_result_sets *
2723 sizeof(**result_sets));
2724 (*result_sets)[0] =
rset;
2727 else if (zs->which == Z_RPNStructure_simple)
2732 if (zs->u.simple->which == Z_Operand_APT)
2734 yaz_log(YLOG_DEBUG,
"rpn_search_APT");
2736 attributeSet, hits_limit,
2737 stream, sort_sequence,
2738 num_bases, basenames, rset_nmem, &
rset,
2743 else if (zs->u.simple->which == Z_Operand_resultSetId)
2745 yaz_log(YLOG_DEBUG,
"rpn_search_ref");
2750 YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST,
2751 zs->u.simple->u.resultSetId);
2761 *num_result_sets = 1;
2762 *result_sets = nmem_malloc(stream, *num_result_sets *
2763 sizeof(**result_sets));
2764 (*result_sets)[0] =
rset;
int attr_find(AttrType *src, const Odr_oid **attribute_set_oid)
void attr_init_APT(AttrType *src, Z_AttributesPlusTerm *zapt, int type)
int attr_find_ex(AttrType *src, const Odr_oid **attribute_set_oid, const char **string_value)
ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *index_type, const char *xpath_use, const Odr_oid *curAttributeSet, int *ord)
char * dict_lookup(Dict dict, const char *p)
lookup item in dictionary
void dict_grep_cmap(Dict dict, void *vp, const char **(*cmap)(void *vp, const char **from, int len))
install character mapping handler for dict_lookup_grep
int dict_lookup_grep(Dict dict, const char *p, int range, void *client, int *max_pos, int init_pos, int(*f)(char *name, const char *info, void *client))
regular expression search with error correction
RSET resultSetRef(ZebraHandle zh, const char *resultSetId)
void zebra_set_partial_result(ZebraHandle zh)
int zebra_term_untrans(ZebraHandle zh, const char *index_type, char *dst, const char *src)
#define FIRST_IN_FIELD_STR
ZEBRA_RES zapt_term_to_utf8(ZebraHandle zh, Z_AttributesPlusTerm *zapt, char *termz)
void zebra_setError(ZebraHandle zh, int code, const char *addinfo)
void zebra_setError_zint(ZebraHandle zh, int code, zint i)
#define FIRST_IN_FIELD_CHAR
RSET rset_trunc(ZebraHandle zh, ISAM_P *isam_p, int no, const char *term, int length_term, const char *flags, int preserve_position, int term_type, NMEM rset_nmem, struct rset_key_control *kctrl, int scope, struct ord_list *ol, const char *index_type, zint hits_limit, const char *term_ref_id)
RSET zebra_create_rset_isam(ZebraHandle zh, NMEM rset_nmem, struct rset_key_control *kctl, int scope, ISAM_P pos, TERMID termid)
void resultSetAddTerm(ZebraHandle zh, ZebraSet s, int reg_type, const char *db, const char *index_name, const char *term)
struct rset_key_control * zebra_key_control_create(ZebraHandle zh)
int key_SU_decode(int *ch, const unsigned char *out)
int key_SU_encode(int ch, char *out)
static void end(struct zebra_register *reg, void *set_handle)
static void add(void *set_handle, int seqno, TERMID term)
#define ZEBRA_XPATH_ELM_END
#define ZEBRA_XPATH_ATTR_CDATA
#define ZEBRA_XPATH_CDATA
#define ZEBRA_XPATH_ELM_BEGIN
#define ZEBRA_GROUP_INDEX_NAME
#define ZEBRA_XPATH_ATTR_NAME
Record rec_get(Records p, zint sysno)
gets record - with given system number
void rec_free(Record *recpp)
frees record (from memory)
const char * res_get(Res r, const char *name)
const char * res_get_def(Res r, const char *name, const char *def)
static void grep_info_delete(struct grep_info *grep_info)
static void esc_str(char *out_buf, size_t out_size, const char *in_buf, int in_size)
static ZEBRA_RES grep_info_prepare(ZebraHandle zh, Z_AttributesPlusTerm *zapt, struct grep_info *grep_info, const char *index_type)
static int term_104(zebra_map_t zm, const char **src, WRBUF term_dict, int space_split, WRBUF display_term)
static ZEBRA_RES rpn_search_APT_or_list(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz_org, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, const char *index_type, int complete_flag, const char *rank_type, const char *xpath_use, NMEM rset_nmem, RSET *rset, struct rset_key_control *kc)
returns result set for or-list search
static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, WRBUF term_dict, const Odr_oid *attributeSet, struct grep_info *grep_info, int *max_pos, zebra_map_t zm, WRBUF display_term, int *error_code)
static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, WRBUF term_dict, const Odr_oid *attributeSet, zebra_map_t zm, int space_split, WRBUF display_term, int *error_code)
static void add_non_space(const char *start, const char *end, WRBUF term_dict, WRBUF display_term, const char **map, int q_map_match)
static RSET xpath_trunc(ZebraHandle zh, NMEM stream, const char *index_type, const char *term, const char *xpath_use, NMEM rset_nmem, struct rset_key_control *kc)
static int term_pre(zebra_map_t zm, const char **src, const char *ct1, int first)
static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const Odr_oid *attributeSet, NMEM stream, Z_SortKeySpecList *sort_sequence, const char *rank_type, NMEM rset_nmem, RSET *rset, struct rset_key_control *kc)
static ZEBRA_RES search_terms_list(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, const char *index_type, int complete_flag, const char *rank_type, const char *xpath_use, NMEM rset_nmem, RSET **result_sets, int *num_result_sets, struct rset_key_control *kc)
Create result set(s) for list of terms.
static int term_101(zebra_map_t zm, const char **src, WRBUF term_dict, int space_split, WRBUF display_term)
void rpn_char_map_prepare(struct zebra_register *reg, zebra_map_t zm, struct rpn_char_map_info *map_info)
static int term_102_icu(zebra_map_t zm, const char **src, WRBUF term_dict, int space_split, WRBUF display_term)
static size_t icu_basechars(const char *buf, size_t i)
static ZEBRA_RES search_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, struct grep_info *grep_info, const char *index_type, int complete_flag, const char *rank_type, const char *xpath_use, NMEM rset_nmem, RSET *rset, struct rset_key_control *kc, zebra_map_t zm, size_t token_number)
search for term (which may be truncated)
static int term_103(zebra_map_t zm, const char **src, WRBUF term_dict, int *errors, int space_split, WRBUF display_term)
static int term_102(zebra_map_t zm, const char **src, WRBUF term_dict, int space_split, WRBUF display_term)
static ZEBRA_RES rpn_search_database(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, Z_SortKeySpecList *sort_sequence, NMEM rset_nmem, RSET *rset, struct rset_key_control *kc)
static const char ** rpn_char_map_handler(void *vp, const char **from, int len)
static int grep_handle(char *name, const char *info, void *p)
static int term_105(zebra_map_t zm, const char **src, WRBUF term_dict, int space_split, WRBUF display_term, int right_truncate)
static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, WRBUF term_dict, const Odr_oid *attributeSet, NMEM stream, struct grep_info *grep_info, const char *index_type, int complete_flag, WRBUF display_term, const char *xpath_use, struct ord_list **ol)
static void gen_regular_rel(WRBUF dst, int val, int islt)
static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, WRBUF term_dict, const Odr_oid *attributeSet, NMEM stream, struct grep_info *grep_info, const char *index_type, int complete_flag, WRBUF display_term, const char *xpath_use, struct ord_list **ol, zebra_map_t zm, size_t token_number)
static int add_isam_p(const char *name, const char *info, struct grep_info *p)
static int term_100_icu(zebra_map_t zm, const char **src, WRBUF term_dict, WRBUF display_term, int mode, size_t token_number)
static ZEBRA_RES rpn_search_xpath(ZebraHandle zh, NMEM stream, const char *rank_type, RSET rset, int xpath_len, struct xpath_location_step *xpath, NMEM rset_nmem, RSET *rset_out, struct rset_key_control *kc)
void string_rel_add_char(WRBUF term_p, WRBUF wsrc, int *indx)
static ZEBRA_RES rpn_search_APT_local(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz, const Odr_oid *attributeSet, NMEM stream, const char *rank_type, NMEM rset_nmem, RSET *rset, struct rset_key_control *kc)
static ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, NMEM rset_nmem, Z_SortKeySpecList *sort_sequence, int num_bases, const char **basenames, RSET **result_sets, int *num_result_sets, Z_Operator *parent_op, struct rset_key_control *kc)
static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, const char *index_type, int complete_flag, const char *rank_type, const char *xpath_use, NMEM rset_nmem, RSET *rset, struct rset_key_control *kc)
ZEBRA_RES zebra_term_limits_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt, zint *hits_limit_value, const char **term_ref_id_str, NMEM nmem)
ZEBRA_RES rpn_get_top_approx_limit(ZebraHandle zh, Z_RPNStructure *zs, zint *approx_limit)
static ZEBRA_RES rpn_search_APT_and_list(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz_org, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, const char *index_type, int complete_flag, const char *rank_type, const char *xpath_use, NMEM rset_nmem, RSET *rset, struct rset_key_control *kc)
returns result set for and-list search
static int rpn_check_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const Odr_oid *attributeSet, struct xpath_location_step *xpath, int max, NMEM mem)
static int term_100(zebra_map_t zm, const char **src, WRBUF term_dict, int space_split, WRBUF display_term)
ZEBRA_RES rpn_search_top(ZebraHandle zh, Z_RPNStructure *zs, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, NMEM rset_nmem, Z_SortKeySpecList *sort_sequence, int num_bases, const char **basenames, RSET *result_set)
static ZEBRA_RES rpn_search_APT_phrase(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz_org, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, const char *index_type, int complete_flag, const char *rank_type, const char *xpath_use, NMEM rset_nmem, RSET *rset, struct rset_key_control *kc)
returns result set for phrase search
static ZEBRA_RES search_position(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const Odr_oid *attributeSet, const char *index_type, NMEM rset_nmem, RSET *rset, struct rset_key_control *kc)
limit a search by position - returns result set
static ZEBRA_RES search_terms_chrmap(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, const char *index_type, int complete_flag, const char *rank_type, const char *xpath_use, NMEM rset_nmem, RSET **result_sets, int *num_result_sets, struct rset_key_control *kc, zebra_map_t zm)
static RSET search_group(ZebraHandle zh, const char *unit, const char *term, NMEM rset_nmem, struct rset_key_control *kc)
static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, Z_SortKeySpecList *sort_sequence, int num_bases, const char **basenames, NMEM rset_nmem, RSET *rset, struct rset_key_control *kc)
void rset_delete(RSET rs)
Destructor RSETs.
RSET rset_create_or(NMEM nmem, struct rset_key_control *kcontrol, int scope, TERMID termid, int no_rsets, RSET *rsets)
RSET rset_create_and(NMEM nmem, struct rset_key_control *kcontrol, int scope, int no_rsets, RSET *rsets)
RSET rset_dup(RSET rs)
Duplicate an RSET.
RSET rset_create_not(NMEM nmem, struct rset_key_control *kcontrol, int scope, RSET rset_l, RSET rset_r)
struct ord_list * ord_list_append(NMEM nmem, struct ord_list *list, int ord)
struct ord_list * ord_list_create(NMEM nmem)
RSET rset_create_between(NMEM nmem, struct rset_key_control *kcontrol, int scope, RSET rset_l, RSET rset_m1, RSET rset_m2, RSET rset_r, RSET rset_attr)
RSET rset_create_null(NMEM nmem, struct rset_key_control *kcontrol, TERMID term)
#define rset_write(rfd, buf)
RSET rset_create_temp(NMEM nmem, struct rset_key_control *kcontrol, int scope, const char *temp_path, TERMID term)
#define rset_open(rs, wflag)
void rset_close(RSFD rfd)
Closes a result set RFD handle.
RSET rset_create_prox(NMEM nmem, struct rset_key_control *kcontrol, int scope, int rset_no, RSET *rset, int ordered, int exclusion, int relation, int distance)
zint mem[IT_KEY_LEVEL_MAX]
void(* dec)(struct rset_key_control *kc)
struct xpath_predicate * predicate
union xpath_predicate::@8 u
struct xpath_predicate::@8::@9 relation
struct zebra_register * reg
zint atozint(const char *src)
short ZEBRA_RES
Common return type for Zebra API.
int zebra_parse_xpath_str(const char *xpath_string, struct xpath_location_step *xpath, int max, NMEM mem)
#define XPATH_PREDICATE_RELATION
int zebra_maps_is_first_in_field(zebra_map_t zm)
int zebra_map_tokenize_next(zebra_map_t zm, const char **result_buf, size_t *result_len, const char **display_buf, size_t *display_len)
int zebra_maps_attr(zebra_maps_t zms, Z_AttributesPlusTerm *zapt, const char **reg_id, char **search_type, char *rank_type, int *complete_flag, int *sort_flag)
int zebra_maps_is_icu(zebra_map_t zm)
int zebra_map_tokenize_start(zebra_map_t zm, const char *buf, size_t len)
const char ** zebra_maps_search(zebra_map_t zm, const char **from, int len, int *q_map_match)
zebra_map_t zebra_map_get_or_add(zebra_maps_t zms, const char *id)
const char ** zebra_maps_input(zebra_map_t zm, const char **from, int len, int first)
int zebraExplain_curDatabase(ZebraExplainInfo zei, const char *database)
int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, zinfo_index_category_t cat, const char *index_type, const char *str)
lookup ordinal from string index + index type
int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord, const char **index_type, const char **db, const char **string_index)
@ zinfo_index_category_index