mirror of
git://jb55.com/damus
synced 2024-09-18 19:23:49 +00:00
nostrdb/search: remove result printing, move to util/ndb
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
aa0b9bde8f
commit
bec92249f9
@ -2561,30 +2561,6 @@ static int ndb_text_search_next_word(MDB_cursor *cursor, MDB_cursor_op op,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ndb_print_text_search_key(struct ndb_text_search_key *key)
|
|
||||||
{
|
|
||||||
printf("K<'%.*s' %d %" PRIu64 " note_id:%" PRIu64 ">", key->str_len, key->str,
|
|
||||||
key->word_index,
|
|
||||||
key->timestamp,
|
|
||||||
key->note_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ndb_print_text_search_result(struct ndb_txn *txn,
|
|
||||||
struct ndb_text_search_result *r)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
struct ndb_note *note;
|
|
||||||
|
|
||||||
ndb_print_text_search_key(&r->key);
|
|
||||||
|
|
||||||
if (!(note = ndb_get_note_by_key(txn, r->key.note_id, &len))) {
|
|
||||||
printf(": note not found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n%s\n\n---\n", ndb_note_str(note, ¬e->content).str);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ndb_text_search_results_init(
|
static void ndb_text_search_results_init(
|
||||||
struct ndb_text_search_results *results) {
|
struct ndb_text_search_results *results) {
|
||||||
results->num_results = 0;
|
results->num_results = 0;
|
||||||
@ -2624,9 +2600,6 @@ int ndb_text_search(struct ndb_txn *txn, const char *query,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "search query: '%s'\n", query);
|
|
||||||
|
|
||||||
|
|
||||||
// for each word, we recursively find all of the submatches
|
// for each word, we recursively find all of the submatches
|
||||||
while (results->num_results < MAX_TEXT_SEARCH_RESULTS) {
|
while (results->num_results < MAX_TEXT_SEARCH_RESULTS) {
|
||||||
last_result = NULL;
|
last_result = NULL;
|
||||||
@ -2635,13 +2608,6 @@ int ndb_text_search(struct ndb_txn *txn, const char *query,
|
|||||||
// if we have saved, then we continue from the last root search
|
// if we have saved, then we continue from the last root search
|
||||||
// sequence
|
// sequence
|
||||||
if (saved) {
|
if (saved) {
|
||||||
/*
|
|
||||||
fprintf(stderr, "continuing from ");
|
|
||||||
if (ndb_unpack_text_search_key(saved_buf, saved_size, &search_key)) {
|
|
||||||
ndb_print_text_search_key(&search_key);
|
|
||||||
}
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
*/
|
|
||||||
buf = saved_buf;
|
buf = saved_buf;
|
||||||
saved = NULL;
|
saved = NULL;
|
||||||
keysize = saved_size;
|
keysize = saved_size;
|
||||||
@ -2738,13 +2704,6 @@ cont:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// print results for now
|
|
||||||
for (j = 0; j < results->num_results; j++) {
|
|
||||||
result = &results->results[j];
|
|
||||||
printf("[%02d] ", j+1);
|
|
||||||
ndb_print_text_search_result(txn, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
mdb_cursor_close(cursor);
|
mdb_cursor_close(cursor);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user