negated search terms
Ted Unangst tedu@tedunangst.com
Thu, 28 Nov 2019 02:14:07 -0500
3 files changed,
25 insertions(+),
4 deletions(-)
M
database.go
→
database.go
@@ -249,8 +249,10 @@ honker := ""
withhonker := 0 site := "" withsite := 0 + withnotq := 0 terms := strings.Split(q, " ") q = "%" + notq := "%" for _, t := range terms { if strings.HasPrefix(t, "site:") { site = t[5:]@@ -267,13 +269,27 @@ }
withhonker = 1 continue } + if t[0] == '-' { + if t == "-" { + continue + } + if len(notq) != 1 { + notq += " " + } + notq += t[1:] + continue + } if len(q) != 1 { q += " " } q += t } q += "%" - rows, err := stmtHonksBySearch.Query(wanted, userid, withsite, site, withhonker, honker, honker, q, userid) + notq += "%" + if notq != "%%" { + withnotq = 1 + } + rows, err := stmtHonksBySearch.Query(wanted, userid, withsite, site, withhonker, honker, honker, q, withnotq, notq, userid) honks := getsomehonks(rows, err) return honks }@@ -748,7 +764,7 @@ stmtHonksISaved = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and flags & 4 order by honks.honkid desc")
stmtHonksByHonker = preparetodie(db, selecthonks+"join honkers on (honkers.xid = honks.honker or honkers.xid = honks.oonker) where honks.honkid > ? and honks.userid = ? and honkers.name = ?"+butnotthose+limit) stmtHonksByXonker = preparetodie(db, selecthonks+" where honks.honkid > ? and honks.userid = ? and (honker = ? or oonker = ?)"+butnotthose+limit) stmtHonksByCombo = preparetodie(db, selecthonks+" where honks.honkid > ? and honks.userid = ? and honks.honker in (select xid from honkers where honkers.userid = ? and honkers.combos like ?) "+butnotthose+" union "+selecthonks+"join onts on honks.honkid = onts.honkid where honks.honkid > ? and honks.userid = ? and onts.ontology in (select xid from honkers where combos like ?)"+butnotthose+limit) - stmtHonksBySearch = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and (? = 0 or xid like ?) and (? = 0 or honks.honker = ? or honks.oonker = ?) and noise like ?"+butnotthose+limit) + stmtHonksBySearch = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and (? = 0 or xid like ?) and (? = 0 or honks.honker = ? or honks.oonker = ?) and noise like ? and (? = 0 or noise not like ?)"+butnotthose+limit) stmtHonksByConvoy = preparetodie(db, selecthonks+"where honks.honkid > ? and (honks.userid = ? or (? = -1 and whofore = 2)) and convoy = ?"+limit) stmtHonksByOntology = preparetodie(db, selecthonks+"join onts on honks.honkid = onts.honkid where honks.honkid > ? and onts.ontology = ? and (honks.userid = ? or (? = -1 and honks.whofore = 2))"+limit)
M
docs/changelog.txt
→
docs/changelog.txt
@@ -2,6 +2,8 @@ changelog
-- next ++ Negated search -terms. + + A raw sendactivity API action for the bold. + More flexible meme names.
M
docs/honk.1
→
docs/honk.1
@@ -143,11 +143,14 @@ .It site
Substring match on the post domain name. .It honker Exact match, either AP actor or honker nickname. +.It - +Negate term. .El .Pp Example: -.Dl honker:goose big moose -This query will find honks by the goose about the big moose. +.Dl honker:goose big moose -footloose +This query will find honks by the goose about the big moose, but excluding +those about footloose. .Ss Filtering Sometimes other users of the federation can get unruly. The honk filtering and censorship system,