View Single Post
Old 03-09-2024, 06:07 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,465
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by DrChiper View Post
This comes to mind in the GUI search field:
Code:
template:"""{series_index}#@#:n:1"""
FWIW: this does the same thing using standard calibre search syntax.
Code:
series:true and series_index:=1
It is possible that the first book in the series doesn't have index 1. This template search finds the lowest index in each series.
Code:
template:"""program:
	vals = globals(vals='');
	if !vals then
		all_series = book_values('series', 'series:true', ',', 0);
		for series in all_series:
			indices = book_values('series_index', 'series:="' & series & '"', ',', 0);
			first = 1;
			lowest = 9999999;
			for index in indices:
				if first || index <# lowest then lowest = index; first = '' fi
			rof;
			vals = list_union(vals, series & ':' & lowest, ',')
		rof;
		set_globals(vals)
	fi;
	if $series && $series_index ==# select(vals, $series) then '1' fi#@#:b:yes"""
If you use the Advanced search dialog, the template is this:
Code:
program:
	vals = globals(vals='');
	if !vals then
		all_series = book_values('series', 'series:true', ',', 0);
		for series in all_series:
			indices = book_values('series_index', 'series:="' & series & '"', ',', 0);
			first = 1;
			lowest = 9999999;
			for index in indices:
				if first || index <# lowest then lowest = index; first = '' fi
			rof;
			vals = list_union(vals, series & ':' & lowest, ',')
		rof;
		set_globals(vals)
	fi;
	if $series && $series_index ==# select(vals, $series) then '1' fi
The template search dialog is this:
Click image for larger version

Name:	Clipboard01.jpg
Views:	77
Size:	71.0 KB
ID:	206787

EDIT: if you store the above as a saved search then you can create a virtual library showing the lowest book.

Last edited by chaley; 03-09-2024 at 06:13 AM.
chaley is offline   Reply With Quote