Notice: My personal stance on AI generated artwork. Retweet and share if you agree. Let us discuss, and not immediately scream bloody murder.

Now Viewing: Is this search logic possible in a single search, or does it need multiple searches?
Keep it civil, do not flame or bait other users. If you notice anything illegal or inappropriate being discussed, contact an administrator or moderator.

smutgoblin - Group: Member - Total Posts: 120
user_avatar
Is this search logic possible in a single search, or does it need multiple searches?
Posted on: 05/27/25 06:01AM

I'm trying to do a search that would accomplish the below, I've looked at the howto:search and howto:cheatsheet wiki pages but not sure if it's possible with the available syntax.

So in a lot of other search engines you can do something like this:
example_artist_name ((red_hair AND green_eyes) OR (blonde_hair AND blue_eyes))

I can't figure out a search that would accomplish this on here, the closest working search I can get is something like this
example_artist_name {red_hair ~ blonde_hair} {green_eyes ~ blue_eyes}
But then I'll also get blondes with green eyes and redheads with blue eyes.

Is it possible or will I need to do multiple searches?



bebop4 - Group: Member - Total Posts: 3
user_avatar
Thought I would take a stab at this
Posted on: 05/29/25 06:45PM

So, since I found your thread while searching for a thread that would just give me the syntax, I looked at the cheat sheet and had a thought. I speculate that it could be in one search if you got really fancy with it. The hard part is that you would have to spell out all the desired permutations that you DON'T want and put that grouping in the search with a NOT operator '-'

That involves an OR clause that has the desired permutations inside as AND clauses, then do the same exercise over the combinations that you don't want and add that to your query behind the NOT operator.

e.g., artist_name {red_hair green_eyes ~ blond_hair blue_eyes} -{red_hair blue_eyes ~ blond_hair green_eyes}

I ran the search above, replacing artist_name with 1girl as such: 1girl {red_hair green_eyes ~ blond_hair blue_eyes} -{red_hair blue_eyes~blond_hair green_eyes}
this syntax returns results, and a quick scan of the first results page yielded no counterexamples that I could see. That said, I am not familiar enough with the search system to definitively validate that this works.

However, I can imagine an edge case where multiple individuals are depicted and one has red_hair but not green_eyes, as long as at least one other character has green_eyes.
I estimate that ruling out the edge cases of this nature would be prohibitively complex, however I wonder if wildcards could be employed to rule out everything else. tbh I can't be arsed to test that because I'm losing interest.

If I had the desire, I would probably figure out the API documentation to return things like count of result set, if extant. I would really like a nap, though, so the rest is left as an exercise for the reader. Have fun....



smutgoblin - Group: Member - Total Posts: 120
user_avatar
Posted on: 05/29/25 06:48PM

Thanks for the detailed reply! I'll give those a try, appreciate it



bebop4 - Group: Member - Total Posts: 3
user_avatar
one more thing
Posted on: 05/29/25 07:07PM

Somehow I accidentally wandered into this thread: gelbooru.com/index.php?page=forum&s=view&id=4555

Seems to be the same question, where one reply mentions the same strategy I proposed above, and called it conjunctive normal form, which it is, but I usually get yelled at if I assume any technical knowledge on the part of my audience. Usually someone would only be familiar with that term if they looked it up themselves, or took a class that includes exploration of more complex boolean logic, or maybe they could be a certain type of savant who could figure out any 3-word combo from context(?)

Fun fact: Some SQL flavors (relational database query language) require CNF and I am not aware of any in the wild that don't work with this. Also at my last job we were required to just default to CNF because it makes the damn code easier to read when you move on to a new position and some poor schmuck inherits the mess of spaghetti that you never got time to comment. There is a more thorough explanation on wikipedia, my favorite site ever: en.wikipedia.org/wiki/Conjunctive_normal_form

PS - I have been that poor schmuck more than once and I wish to never inflict that pain on anyone else. Don't get me started on how terrible JS is to have to debug when you didn't personally write it!

Yay science! lol



Abtuse - Group: Member - Total Posts: 8
user_avatar
Posted on: 06/05/25 04:24AM

Possibly related to issue gelbooru.com/index.php?page=tracker&s=view&id=1361
Far as I'm aware this isn't something you can do, unfortunately.



add_replyAdd Reply