},
{
.idx = RSPAMD_FUZZY_BACKEND_CHECK_SHINGLE,
- .sql = "SELECT digest_id FROM shingles WHERE value=? AND number=?",
+ .sql = "SELECT digest_id FROM shingles WHERE value=?1 AND number=?2",
.args = "IS",
.stmt = NULL,
.result = SQLITE_ROW
},
{
.idx = RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID,
- .sql = "SELECT digest, value, time, flag FROM digests WHERE id=?",
+ .sql = "SELECT digest, value, time, flag FROM digests WHERE id=?1",
.args = "I",
.stmt = NULL,
.result = SQLITE_ROW
else {
shingle_values[i] = -1;
}
+ msg_debug ("looking for shingle %d -> %L: %d", i, shcmd->sgl.hashes[i], rc);
}
qsort (shingle_values, RSPAMD_SHINGLE_SIZE, sizeof (gint64),
rspamd_fuzzy_backend_int64_cmp);
if (sel_id != -1) {
/* We have some id selected here */
rep.prob = (gdouble)max_cnt / (gdouble)RSPAMD_SHINGLE_SIZE;
+ msg_debug ("found fuzzy hash with probability %.2f", rep.prob);
rc = rspamd_fuzzy_backend_run_stmt (backend,
RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID, sel_id);
if (rc == SQLITE_OK) {
rspamd_fuzzy_backend_run_stmt (backend,
RSPAMD_FUZZY_BACKEND_INSERT_SHINGLE,
shcmd->sgl.hashes[i], i, id);
+ msg_debug ("add shingle %d -> %L: %d", i, shcmd->sgl.hashes[i], id);
}
}
}
k = "rspamd";
}
rule->shingles_key = g_string_sized_new (16);
- blake2 (rule->hash_key->str, k, NULL, 16, strlen (k), 0);
- rule->hash_key->len = 16;
+ blake2 (rule->shingles_key->str, k, NULL, 16, strlen (k), 0);
+ rule->shingles_key->len = 16;
if (rspamd_upstreams_count (rule->servers) == 0) {
msg_err ("no servers defined for fuzzy rule with symbol: %s",
}
blake2b_final (&st, shcmd->basic.digest, sizeof (shcmd->basic.digest));
+ msg_debug ("loading shingles with key %*xs", 16, rule->shingles_key->str);
sh = rspamd_shingles_generate (part->words, rule->shingles_key->str,
pool, rspamd_shingles_default_filter, NULL);
if (sh != NULL) {