- char start_str[10], count_str[10];
-
- if (next_token_copy (args, start_str, sizeof(start_str)))
- ZOOM_options_set (options, "start", start_str);
-
- if (next_token_copy (args, count_str, sizeof(count_str)))
- ZOOM_options_set (options, "count", count_str);
-
- for (i = 0; i<MAX_CON; i++)
- ZOOM_resultset_records (r[i], 0, atoi(start_str), atoi(count_str));
- while (ZOOM_event (MAX_CON, c))
- ;
-
- for (i = 0; i<MAX_CON; i++)
- {
- int error;
- const char *errmsg, *addinfo;
- /* display errors if any */
- if (!c[i])
- continue;
- if ((error = ZOOM_connection_error(c[i], &errmsg, &addinfo)))
- fprintf (stderr, "%s error: %s (%d) %s\n",
- ZOOM_connection_option_get(c[i], "host"), errmsg,
- error, addinfo);
- else if (r[i])
- {
- /* OK, no major errors. Display records... */
- int start = ZOOM_options_get_int (options, "start", 0);
- int count = ZOOM_options_get_int (options, "count", 0);
- display_records (c[i], r[i], start, count);
- }
+ printf("Facets: \n");
+ for (i = 0; i < count; i++)
+ {
+ int j;
+ const char *facet_name = ZOOM_facet_field_name(facets[i]);
+ printf(" %s: \n", facet_name);
+ for (j = 0; j < ZOOM_facet_field_term_count(facets[i]); j++)
+ {
+ int freq = 0;
+ const char *term = ZOOM_facet_field_get_term(facets[i], j, &freq);
+ printf(" %s(%d) \n", term, freq);
+ }
+ }
+}
+
+static int cmd_facets(struct zoom_sh *sh, const char **args)
+{
+ struct zoom_db *db;
+ int ret = 0;
+
+ process_events(sh);
+
+ for (db = sh->list; db; db = db->next)
+ {
+ int error;
+ const char *errmsg, *addinfo, *dset;
+ /* display errors if any */
+ if (!db->con)
+ continue;
+ if ((error = ZOOM_connection_error_x(db->con, &errmsg, &addinfo,
+ &dset)))
+ {
+ printf("%s error: %s (%s:%d) %s\n",
+ ZOOM_connection_option_get(db->con, "host"), errmsg,
+ dset, error, addinfo);
+ ret = 1;
+ }
+ else if (db->res)
+ {
+ int num_facets = ZOOM_resultset_facets_size(db->res);
+ if (num_facets) {
+ ZOOM_facet_field *facets = ZOOM_resultset_facets(db->res);
+ display_facets(facets, num_facets);
+ }
+ }
+ }
+ return ret;
+}
+
+static int cmd_suggestions(struct zoom_sh *sh, const char **args)
+{
+ struct zoom_db *db;
+ int ret = 0;
+
+ process_events(sh);
+
+ for (db = sh->list; db; db = db->next)
+ {
+ int error;
+ const char *errmsg, *addinfo, *dset;
+ /* display errors if any */
+ if (!db->con)
+ continue;
+ if ((error = ZOOM_connection_error_x(db->con, &errmsg, &addinfo,
+ &dset)))
+ {
+ printf("%s error: %s (%s:%d) %s\n",
+ ZOOM_connection_option_get(db->con, "host"), errmsg,
+ dset, error, addinfo);
+ ret = 1;
+ }
+ else if (db->res)
+ {
+ const char *suggestions =
+ ZOOM_resultset_option_get(db->res, "suggestions");
+ if (suggestions)
+ printf("Suggestions: \n%s\n", suggestions);
+ }
+ }
+ return ret;
+}
+
+static int cmd_ext(struct zoom_sh *sh, const char **args)
+{
+ int ret = 0;
+ ZOOM_package *p = 0;
+ struct zoom_db *db;
+ int i, number;
+ WRBUF ext_type_str = next_token_new_wrbuf(args);
+
+ if (!ext_type_str)
+ {
+ printf("es: missing type "
+ "(itemorder, create, drop, commit, update, xmlupdate)\n");
+ return 1;
+ }
+ for (number = 0, db = sh->list; db; db = db->next)
+ if (db->con)
+ number++;
+
+ p = xmalloc(sizeof(*p) * number);
+
+ for (i = 0, db = sh->list; db; db = db->next)
+ if (db->con)
+ {
+ p[i] = ZOOM_connection_package(db->con, 0);
+ ZOOM_package_send(p[i], ext_type_str ? wrbuf_cstr(ext_type_str):0);
+ i++;
+ }
+
+ process_events(sh);
+
+ for (i = 0, db = sh->list; db; db = db->next)
+ {
+ int error;
+ const char *errmsg, *addinfo, *dset;
+ /* display errors if any */
+ if (!db->con)
+ continue;
+ if ((error = ZOOM_connection_error_x(db->con, &errmsg, &addinfo,
+ &dset)))
+ {
+ printf("%s error: %s (%s:%d) %s\n",
+ ZOOM_connection_option_get(db->con, "host"), errmsg,
+ dset, error, addinfo);
+ ret = 1;
+ }
+ else if (p[i])
+ {
+ const char *v;
+ printf("ok\n");
+ v = ZOOM_package_option_get(p[i], "targetReference");
+ if (v)
+ printf("targetReference: %s\n", v);
+ v = ZOOM_package_option_get(p[i], "xmlUpdateDoc");
+ if (v)
+ printf("xmlUpdateDoc: %s\n", v);
+ }
+ ZOOM_package_destroy(p[i]);
+ i++;