+ struct it_key key;
+ ZebraHandle zh = p->extractCtrl->handle;
+ ZebraExplainInfo zei = zh->reg->zei;
+ int ch, i;
+
+ ch = zebraExplain_lookup_attr_str(zei, cat, p->index_type, p->index_name);
+ if (ch < 0)
+ ch = zebraExplain_add_attr_str(zei, cat, p->index_type, p->index_name);
+
+ i = 0;
+ key.mem[i++] = ch;
+ key.mem[i++] = p->record_id;
+ key.mem[i++] = p->section_id;
+
+ if (zh->m_segment_indexing)
+ key.mem[i++] = p->segment;
+ key.mem[i++] = p->seqno;
+ key.len = i;
+
+ zebra_rec_keys_write(zh->reg->keys, str, length, &key);
+}
+
+static void extract_add_sort_string(RecWord *p, const char *str, int length)
+{
+ struct it_key key;
+ ZebraHandle zh = p->extractCtrl->handle;
+ ZebraExplainInfo zei = zh->reg->zei;
+ int ch;
+ zinfo_index_category_t cat = zinfo_index_category_sort;
+
+ ch = zebraExplain_lookup_attr_str(zei, cat, p->index_type, p->index_name);
+ if (ch < 0)
+ ch = zebraExplain_add_attr_str(zei, cat, p->index_type, p->index_name);
+ key.len = 3;
+ key.mem[0] = ch;
+ key.mem[1] = p->record_id;
+ key.mem[2] = p->section_id;
+
+ zebra_rec_keys_write(zh->reg->sortKeys, str, length, &key);
+}
+
+static void extract_add_staticrank_string(RecWord *p,
+ const char *str, int length)
+{
+ char valz[40];
+ struct recExtractCtrl *ctrl = p->extractCtrl;
+
+ if (length > sizeof(valz)-1)
+ length = sizeof(valz)-1;
+
+ memcpy(valz, str, length);
+ valz[length] = '\0';
+ ctrl->staticrank = atozint(valz);
+}
+
+static void extract_add_string(RecWord *p, zebra_map_t zm,
+ const char *string, int length)
+{
+ assert(length > 0);
+
+ if (!p->index_name)
+ return;
+ if (log_level_details)
+ {
+
+ WRBUF w = wrbuf_alloc();
+
+ wrbuf_write_escaped(w, string, length);
+ yaz_log(log_level_details, "extract_add_string: %s", wrbuf_cstr(w));
+ wrbuf_destroy(w);
+ }
+ if (zebra_maps_is_index(zm))
+ {
+ extract_add_index_string(p, zinfo_index_category_index,
+ string, length);
+ if (zebra_maps_is_alwaysmatches(zm))
+ {
+ RecWord word;
+ memcpy(&word, p, sizeof(word));
+
+ word.seqno = 1;
+ extract_add_index_string(
+ &word, zinfo_index_category_alwaysmatches, "", 0);
+ }
+ }
+ else if (zebra_maps_is_sort(zm))
+ {
+ extract_add_sort_string(p, string, length);
+ }
+ else if (zebra_maps_is_staticrank(zm))
+ {
+ extract_add_staticrank_string(p, string, length);
+ }