Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 11-18-2011, 10:58 AM   #1
KABx
Junior Member
KABx began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2011
Device: kindle
Help with search query

I’m sure this is very easy, but I can’t quite get it.....can anyone help with a couple of search queries?

I have 2 custom columns (both comma separated text, like tags, shown in the tag browser).

How do I do search for

columnA not = columnB

and

columnA contains columnB ?
KABx is offline   Reply With Quote
Old 11-18-2011, 11:13 AM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by KABx View Post
I’m sure this is very easy, but I can’t quite get it.....can anyone help with a couple of search queries?

I have 2 custom columns (both comma separated text, like tags, shown in the tag browser).

How do I do search for

columnA not = columnB

and

columnA contains columnB ?
Use the Tag Browser Luke

Set it to Match All at the bottom
Select the first column value (minus is Not)
hold the control key
Select the second column value (Minus is Not)

you should see something like this:
Code:
tags:"=Webscription" and  not #usertags:"=Not All Done Yet"
theducks is online now   Reply With Quote
Advert
Old 11-18-2011, 11:20 AM   #3
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: 12,444
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Calibre does not support search expressions referencing more than one column.

One way to do this in the GUI is to create a composite custom column (column built from other columns) that produces a true/false value based on the values in other columns. The computations can be slow, but it does work. For example, the first search would be done by creating a column that uses the list_equals function. Implementation of the second depends on exactly what you mean by 'contains'. If you mean 'all items in columnB are in columnA, then one would use both list_intersection and list_equals. If you mean 'any item in columnB is in columnA', then it would be list_intersection and count. If columnB contains only one value, then you can use in_list. The performance problems can be largely avoided by using custom template functions.

You could write a plugin that does the search. Such a plugin would be faster than custom template functions and would obviate the need for extra columns.

Finally, you can write SQL against calibre's DB. This would be complicated, both because getting the answers back into the GUI is hard and because list manipulation is not easy in SQL.
chaley is offline   Reply With Quote
Old 11-18-2011, 11:56 AM   #4
KABx
Junior Member
KABx began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2011
Device: kindle
Quote:
Originally Posted by theducks View Post
Use the Tag Browser Luke

Set it to Match All at the bottom
Select the first column value (minus is Not)
hold the control key
Select the second column value (Minus is Not)

you should see something like this:
Code:
tags:"=Webscription" and  not #usertags:"=Not All Done Yet"

Calibre’s strength flows from the tag browser..... but it is not the solution this time


Quote:
Originally Posted by chaley View Post
Calibre does not support search expressions referencing more than one column.

One way to do this in the GUI is to create a composite custom column (column built from other columns) that produces a true/false value based on the values in other columns. The computations can be slow, but it does work. For example, the first search would be done by creating a column that uses the list_equals function. Implementation of the second depends on exactly what you mean by 'contains'. If you mean 'all items in columnB are in columnA, then one would use both list_intersection and list_equals. If you mean 'any item in columnB is in columnA', then it would be list_intersection and count. If columnB contains only one value, then you can use in_list. The performance problems can be largely avoided by using custom template functions.

You could write a plugin that does the search. Such a plugin would be faster than custom template functions and would obviate the need for extra columns.

Finally, you can write SQL against calibre's DB. This would be complicated, both because getting the answers back into the GUI is hard and because list manipulation is not easy in SQL.

....and there was me thinking it would be easy!

Give me an IBM mainframe and DB2 and i can manage SQL, but its a bit beyond me on a PC.... so is a calibre plugin. I'm still learning how to use them, can't cope with writing one too


I will have a play with the composite column route and see if i can work it out.

thanks for the suggestions.
KABx is offline   Reply With Quote
Old 11-18-2011, 12:04 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: 12,444
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Here is one possible template for the column used for the first search:
Code:
program: list_equals(field('#columnA'), ',', field('#columnB'), ',', 'yes', 'no')

Last edited by chaley; 11-18-2011 at 01:02 PM. Reason: fix grammar
chaley is offline   Reply With Quote
Advert
Old 11-18-2011, 12:27 PM   #6
KABx
Junior Member
KABx began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2011
Device: kindle
Quote:
Originally Posted by chaley View Post
Here is one possible template a the column used for the first search:
Code:
program: list_equals(field('#columnA'), ',', field('#columnB'), ',', 'yes', 'no')

thanks - that was just what I needed to get me on the right track - i've not got the hang of the syntax of everything yet. Once I have an example, I can usually work it out.

I've got the A=B bit working now, I suspect the next one will be a bit harder
KABx is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Firmware query Orn8one Sony Reader 9 10-12-2011 07:15 PM
Problem using 'Advanced Search' with 'Search in Forum' Wetdogeared Feedback 6 06-21-2011 09:37 AM
Query - Kindle DX US ukhant Kindle Developer's Corner 2 07-20-2010 03:23 AM
BooksOn Board Query - Search & Wishlist Mindy Lounge 0 08-29-2008 10:30 AM
Google Book Search to search full-text books online Bob Russell Deals and Resources (No Self-Promotion or Affiliate Links) 1 08-19-2006 12:13 PM


All times are GMT -4. The time now is 11:40 PM.


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