Danbooru

Saved searches and OR(~) operator not working

Posted under Bugs & Features

incubatedveg said:

shouldnt a search with "~sweat ~dirty *cloth*" require posts to be tagged with either sweat or dirty or both? cause what comes up is not that. also, i have saved this search and am encountering some weird stuff with tags not even mattering? not sure if anyone else can see my searched tags but ill link it anyway: https://danbooru.donmai.us/posts?tags=search%3Amechanic1

No, nobody can see your search. It's not a saved search-specific issue, ~sweat ~dirty *cloth* returns unexpected results because *cloth* is effectively a massive OR search with the top 100 tags matching *cloth*.

incubatedveg said:

but doesnt it still require at least one of the other two tags to show the post? if not, why is that

No, because it's a giant OR search. ~sweat ~dirty *cloth* becomes something like ~sweat ~cloth ~japanese_clothes ~open_clothes ....

Talulah said:

No, because it's a giant OR search. ~sweat ~dirty *cloth* becomes something like ~sweat ~cloth ~japanese_clothes ~open_clothes ....

oh, interesting. how do i tell it where the OR stuff begins and ends? and can i have multiple OR stuff for the same search? like this
(Open_shirt open_clothes topless) AND (4girls 5girls 6+girls) would show posts that have some kind of clothed nudity as well as 4 or more females

Talulah said:

I don't think there's any way to do that at present. The query builder does not currently support subqueries like that.

hm... not even with searches? if i had the first perintheses in one search and second perintheses in another, then do "search:partone search:parttwo" wouldnt work either huh

incubatedveg said:

hm... not even with searches? if i had the first perintheses in one search and second perintheses in another, then do "search:partone search:parttwo" wouldnt work either huh

With saved searches you might be able to. But since saved searches are limited to 1000 posts each, you'll likely end up with a very small overlap. It might not even fill a single page.

incubatedveg said:

hm... not even with searches? if i had the first perintheses in one search and second perintheses in another, then do "search:partone search:parttwo" wouldnt work either huh

(a OR b) AND (x OR y) is possible with two saved searches, but as Talulah said, each saved search is limited to 1000 results. By default, that’s the 1000 most recent results, but you can add "order:score" to select the 1000 best-scoring posts instead, which will probably be missing anything recent. If you go to the  saved search manager, you can check if you’re hitting the 1000 post limit on any of the searches.

"~sweat ~dirty *cloth*" is treated like "sweat OR dirty OR *cloth*". Arguably this is a bug and it should work like "(sweat OR dirty) AND *cloth*". Changing this however may break other people's searches that expect it to work the way it currently does.

What you probably want is ~sweat ~dirty -nude. -nude will find people wearing clothing (not nude). *cloth* won't match most common clothing tags like shirt or pants, but will match tags like tablecloth, clothed pokemon, and clothed male nude female, that you probably don't want.

evazion said:

"~sweat ~dirty *cloth*" is treated like "sweat OR dirty OR *cloth*". Arguably this is a bug and it should work like "(sweat OR dirty) AND *cloth*". Changing this however may break other people's searches that expect it to work the way it currently does.

What you probably want is ~sweat ~dirty -nude. -nude will find people wearing clothing (not nude). *cloth* won't match most common clothing tags like shirt or pants, but will match tags like tablecloth, clothed pokemon, and clothed male nude female, that you probably don't want.

Thanks! what you said makes sense, but does seem like a bug. why would "~sweat ~dirty -nude" not be the same as ""sweat OR dirty OR -nude"?

incubatedveg said:

Thanks! what you said makes sense, but does seem like a bug. why would "~sweat ~dirty -nude" not be the same as ""sweat OR dirty OR -nude"?

It wouldn't make much sense for negated terms to be optional like that. If you're searching for -nude you probably don't want to see nude just because the post is tagged sweat/dirty.

Talulah said:

It wouldn't make much sense for negated terms to be optional like that. If you're searching for -nude you probably don't want to see nude just because the post is tagged sweat/dirty.

thats my point, since you said above that it treats everything after a ~ sign with the OR parameter. which is kind of dumb lol.

incubatedveg said:

thats my point, since you said above that it treats everything after a ~ sign with the OR parameter. which is kind of dumb lol.

Everything directly after a ~ sign, that is. ~A ~B C means that C must be present even though there’s a tilde somewhere in front of it, because the tilde is not directly in front of it.

kittey said:

Everything directly after a ~ sign, that is. ~A ~B C means that C must be present even though there’s a tilde somewhere in front of it, because the tilde is not directly in front of it.

that contradicts the 2nd/3rd comments in this thread though? ~sweat ~dirty *cloth* should require one of the first two, as well as something containing cloth? but instead it treats each query as optional

No, you're not understanding. *cloth* is expanded to something like ~japanese_clothes ~open_clothes ~clothes_lift ~torn_clothes ~clothing_cutout ~chinese_clothes ~clothes_pull (and more) and then spliced into your query. Since wildcards work by ORing all the matching tags together, it means using it with a regular OR search has unexpected results.

Talulah said:

No, you're not understanding. *cloth* is expanded to something like ~japanese_clothes ~open_clothes ~clothes_lift ~torn_clothes ~clothing_cutout ~chinese_clothes ~clothes_pull (and more) and then spliced into your query. Since wildcards work by ORing all the matching tags together, it means using it with a regular OR search has unexpected results.

i see now. is there any way to search for matching expressions with a leading * without including the ~?

Without ORing them it would be asking for posts that contain all matching tags, which likely isn't what you want either. I opened issue #5056 for this, since this isn't the first time the behavior of wildcard searches has caused confusion. I don't know if there is any good alternative until/unless something is changed in Danbooru's code.

1 2