shimmie2 icon indicating copy to clipboard operation
shimmie2 copied to clipboard

Add disjunctive search operation

Open discomrade opened this issue 1 year ago • 3 comments

This commit adds the disjunctive operands to search, e.g. ~computer ~thing ~score:>5 (means: computer OR thing OR score:>5), as well as negative disjunctive operands e.g. ~cat ~-phone (means: cat OR NOT phone). This also works with image conditions.

While I believe this operation is acceptably efficient for legitimate use, it's probably wise to add limits, especially for SPEED_HAX, but for security in general. Abusing wildcards (or really just a huge number of tags) compounds with negated disjunction e.g. searching ~-*f* ~-*a* ~-*s* ~-*t* is an effective DoS attack on a decent-sized booru, even just two of those letters forces my (20,000 image, 7,000 tags) test booru into 14 seconds of computation. Maybe make negated disjunction disabled or limited by default?

Closes #292 Closes #824 Built on top of #1082

discomrade avatar Feb 24 '24 22:02 discomrade

(Sorry for the delays here - this seems pretty great but I have some foundational bits I'd like to merge first and things at my day job got hectic which has been taking my code time ^^;; )

shish avatar Apr 27 '24 22:04 shish

No problem :) This one is big and has the mentioned caveats, so definitely best not to rush it.

discomrade avatar Apr 28 '24 11:04 discomrade

Marked as draft to avoid this being merged as-is:

  • The current code is capable of malicious DoS abuse and does not yet have sane default settings to mitigate this risk.
  • If #1153 is merged, this will require significant refactoring. This code should be rewritten and resubmitted after that pull request is accepted.

discomrade avatar May 15 '24 23:05 discomrade