Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 02-11-2024, 03:20 PM   #1
groob
Enthusiast
groob began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Oct 2020
Device: Kindle Paperwhite (1)
Unhappy Search for book in top category only

Hello,
I have a custom category `genre` that contains sub categories, for example:

Code:
entertainment
entertainment.comicbook
entertainment.humor
entertainment.music
entertainment.storytelling
entertainment.television
entertainment.writing
Now, how can I find out all the books that belong to the `#genre:"=entertainment"` top level only?

Meaning all the books that have an assigned category `entertainment` BUT NONE of the subcategories of `entertainment`?

I have tried this search but it doesn't work:

Code:
#genre:"=entertainment" AND NOT #genre:"=.entertainment"
Even if there is a book with just the top level `entertainment` applied with none of the subcategories the results are empty

Any idea?
groob is offline   Reply With Quote
Old 02-11-2024, 05:35 PM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,598
Karma: 6146321
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Use the tag browser to see what the search expressions are. For example, click on the "entertainment" genre until you see a green single + sign then look at the search bar.

For more information see "‘Equality’ searches" in "The search interface" in the calibre manual.
chaley is offline   Reply With Quote
Old 02-11-2024, 05:40 PM   #3
groob
Enthusiast
groob began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Oct 2020
Device: Kindle Paperwhite (1)
Quote:
Originally Posted by chaley View Post
For example, click on the "entertainment" genre until you see a green single + sign then look at the search bar.
I know, that produces
Code:
#genre:"=entertainment"
What I don't know is how to search for sub-categories only. Because this

Code:
#genre:"=.entertainment"
(notice the dot) will search entertainment and all its subcategories.
groob is offline   Reply With Quote
Old 02-11-2024, 05:44 PM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,598
Karma: 6146321
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by groob View Post
Now, how can I find out all the books that belong to the `#genre:"=entertainment"` top level only?
Quote:
Originally Posted by groob View Post
I know, that produces
What I don't know is how to search for sub-categories only. Because this
Those are not the same question.

What exactly do you want to do?
chaley is offline   Reply With Quote
Old 02-11-2024, 06:02 PM   #5
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,598
Karma: 6146321
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
If your second post is the question you are asking, then this
Code:
#genre:"=.entertainment" and not #genre:"=entertainment"
or this
Code:
#genre:"~^entertainment\."
chaley is offline   Reply With Quote
Old 02-11-2024, 11:27 PM   #6
groob
Enthusiast
groob began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Oct 2020
Device: Kindle Paperwhite (1)
Quote:
Originally Posted by chaley View Post
If your second post is the question you are asking, then this
Code:
#genre:"=.entertainment" and not #genre:"=entertainment"
or this
Code:
#genre:"~^entertainment\."
Thanks for your help,
I'll try to be more clear:
- I have some books that have the top category only, and some books that have the top category AND any of the subcategories.
- I need to search which books having the top category don't have any additional subcategories assigned.

So logically it would be: lookup the top category only AND exclude any subcategory, but again, my example and also your examples do not work.

To me this should be correct:
Code:
#genre:"=entertainment" AND NOT #genre:"=.entertainment"
but it's not.
groob is offline   Reply With Quote
Old 02-12-2024, 02:35 AM   #7
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 33,506
Karma: 142904165
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Something like this with the '.' moved after entertainment?

Code:
#genre:"=entertainment" AND NOT #genre:"=entertainment."
What does a simple sort on the genre column show since entertainment should sort ahead of entertainment. ?
DNSB is offline   Reply With Quote
Old 02-12-2024, 03:12 AM   #8
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,598
Karma: 6146321
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by groob View Post
Thanks for your help,
I'll try to be more clear:
- I have some books that have the top category only, and some books that have the top category AND any of the subcategories.
- I need to search which books having the top category don't have any additional subcategories assigned.

So logically it would be: lookup the top category only AND exclude any subcategory, but again, my example and also your examples do not work.

To me this should be correct:
Code:
#genre:"=entertainment" AND NOT #genre:"=.entertainment"
but it's not.
That is question #1 again.

This search, produced by the tag browser when the single green plus is showing
Code:
#genre:"=entertainment"
finds all books with the genre "entertainment" but no subgenres of entertainment.

Examples:
  • Only the top level genre entertainment. Note that the number of books shown, 1, equals the count in the total count of the category minus the sum of the count of the children:
    Click image for larger version

Name:	Clipboard01.jpg
Views:	21
Size:	24.5 KB
ID:	206319
  • The top level and all its children. The number of books, 13, equals the total on the top level item:
    Click image for larger version

Name:	Clipboard03.jpg
Views:	22
Size:	93.6 KB
ID:	206320
  • Only the children. This search combines the 2 above searches. The count, 12, equals the sum of the counts of the children:
    Click image for larger version

Name:	Clipboard04.jpg
Views:	21
Size:	89.1 KB
ID:	206321
chaley is offline   Reply With Quote
Old 02-13-2024, 05:20 PM   #9
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,598
Karma: 6146321
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by groob View Post
Thanks for your help,
I'll try to be more clear:
[...]
I realized I misunderstood your posts. My apologies. And sorry for being super pedantic in this post. I am "thinking out loud".

To rephrase the question using sets, what (I think) you want is the intersection of two sets
Code:
top_level_set ⋂ ~set_of_children
where
  • top_level_set is the books that contain the bare (top-level) genre "entertainment".
  • set_of_children is the books that contain children of "entertainment".

Computing top_level_set is easy using the search
Code:
#genre:"=entertainment"
Computing set_of_children is more problematic. As you noted, the search
Code:
#genre:"=.entertainment"
can't be used for set_of_children because the search builds the set
Code:
(top_level_set ∪ set_of_children)
The expression
Code:
top_level_set ⋂ ~(top_level_set ∪ set_of_children)
is the empty set.

We must find a search that finds children of entertainment, ignoring entertainment itself. The regexp search in post #5 and alluded to by @DNSB in post 7
Code:
#genre:"~^entertainment\."
builds set_of_children by finding the set of books where "entertainment" is followed by a period.

Putting the two together, the search
Code:
#genre:"=entertainment" AND NOT #genre:"~^entertainment\."
builds the intersection we want
Code:
top_level_set ⋂ ~set_of_children
These screen captures shows that the search works. The first shows the books without a search. The second shows the books after applying the search.
Attached Thumbnails
Click image for larger version

Name:	Clipboard03.jpg
Views:	20
Size:	37.8 KB
ID:	206376   Click image for larger version

Name:	Clipboard02.jpg
Views:	18
Size:	27.0 KB
ID:	206377  

Last edited by chaley; 02-13-2024 at 08:57 PM.
chaley is offline   Reply With Quote
Reply

Tags
categories, category, genre, genre hierarchy, search

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and Go To controls at the top lucille Viewer 4 04-12-2022 03:52 AM
How to create virtual library to match the top most level category. hlhp Library Management 2 03-21-2021 09:01 AM
Saved Search window off top of screen? Phssthpok Editor 2 11-26-2020 06:13 AM
Putting sideloaded book in the Books category instead of Docs category hopla Amazon Kindle 5 10-29-2018 07:40 PM
Smart Search when Adding Category Information Teeg Calibre 1 04-11-2018 08:59 AM


All times are GMT -4. The time now is 12:28 AM.


MobileRead.com is a privately owned, operated and funded community.