mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-26 10:00:37 +00:00
Fix for unicode search (#426)
This commit is contained in:
parent
ff2d53b998
commit
f019d58b4d
23
cps/web.py
23
cps/web.py
@ -666,12 +666,12 @@ def feed_search(term):
|
|||||||
if term:
|
if term:
|
||||||
term = term.strip().lower()
|
term = term.strip().lower()
|
||||||
db.session.connection().connection.connection.create_function("lower", 1, db.lcase)
|
db.session.connection().connection.connection.create_function("lower", 1, db.lcase)
|
||||||
entries = db.session.query(db.Books).filter(db.or_(db.Books.tags.any(db.Tags.name.ilike("%" + term + "%")),
|
entries = db.session.query(db.Books).filter(common_filters()).filter(
|
||||||
|
db.or_(db.Books.tags.any(db.Tags.name.ilike("%" + term + "%")),
|
||||||
db.Books.series.any(db.Series.name.ilike("%" + term + "%")),
|
db.Books.series.any(db.Series.name.ilike("%" + term + "%")),
|
||||||
db.Books.authors.any(db.Authors.name.ilike("%" + term + "%")),
|
db.Books.authors.any(db.Authors.name.ilike("%" + term + "%")),
|
||||||
db.Books.publishers.any(db.Publishers.name.ilike("%" + term + "%")),
|
db.Books.publishers.any(db.Publishers.name.ilike("%" + term + "%")),
|
||||||
db.Books.title.ilike("%" + term + "%")))\
|
db.Books.title.ilike("%" + term + "%"))).all()
|
||||||
.filter(common_filters()).all()
|
|
||||||
entriescount = len(entries) if len(entries) > 0 else 1
|
entriescount = len(entries) if len(entries) > 0 else 1
|
||||||
pagination = Pagination(1, entriescount, entriescount)
|
pagination = Pagination(1, entriescount, entriescount)
|
||||||
xml = render_title_template('feed.xml', searchterm=term, entries=entries, pagination=pagination)
|
xml = render_title_template('feed.xml', searchterm=term, entries=entries, pagination=pagination)
|
||||||
@ -1667,12 +1667,13 @@ def search():
|
|||||||
|
|
||||||
if term:
|
if term:
|
||||||
db.session.connection().connection.connection.create_function("lower", 1, db.lcase)
|
db.session.connection().connection.connection.create_function("lower", 1, db.lcase)
|
||||||
entries = db.session.query(db.Books).filter(db.or_(db.Books.tags.any(db.Tags.name.ilike("%" + term + "%")),
|
entries = db.session.query(db.Books).filter(common_filters()).filter(
|
||||||
|
db.or_(db.Books.tags.any(db.Tags.name.ilike("%" + term + "%")),
|
||||||
db.Books.series.any(db.Series.name.ilike("%" + term + "%")),
|
db.Books.series.any(db.Series.name.ilike("%" + term + "%")),
|
||||||
db.Books.authors.any(db.Authors.name.ilike("%" + term + "%")),
|
db.Books.authors.any(db.Authors.name.ilike("%" + term + "%")),
|
||||||
db.Books.publishers.any(db.Publishers.name.ilike("%" + term + "%")),
|
db.Books.publishers.any(db.Publishers.name.ilike("%" + term + "%")),
|
||||||
db.Books.title.ilike("%" + term + "%")))\
|
db.Books.title.ilike("%" + term + "%"))).all()
|
||||||
.filter(common_filters()).all()
|
|
||||||
# entries = db.session.query(db.Books).with_entities(db.Books.title).filter(db.Books.title.ilike("%" + term + "%")).all()
|
# entries = db.session.query(db.Books).with_entities(db.Books.title).filter(db.Books.title.ilike("%" + term + "%")).all()
|
||||||
# result = db.session.execute("select name from authors where lower(name) like '%" + term.lower() + "%'")
|
# result = db.session.execute("select name from authors where lower(name) like '%" + term.lower() + "%'")
|
||||||
# entries = result.fetchall()
|
# entries = result.fetchall()
|
||||||
@ -1719,9 +1720,13 @@ def advanced_search():
|
|||||||
lang.name = _(isoLanguages.get(part3=lang.lang_code).name)
|
lang.name = _(isoLanguages.get(part3=lang.lang_code).name)
|
||||||
searchterm.extend(language.name for language in language_names)
|
searchterm.extend(language.name for language in language_names)
|
||||||
searchterm = " + ".join(filter(None, searchterm))
|
searchterm = " + ".join(filter(None, searchterm))
|
||||||
q = q.filter(db.Books.authors.any(db.Authors.name.ilike("%" + author_name + "%")),
|
q = q.filter()
|
||||||
db.Books.title.ilike("%" + book_title + "%"),
|
if author_name:
|
||||||
db.Books.publishers.any(db.Publishers.name.ilike("%" + publisher + "%")))
|
q = q.filter(db.Books.authors.any(db.Authors.name.ilike("%" + author_name + "%")))
|
||||||
|
if book_title:
|
||||||
|
q = q.filter(db.Books.title.ilike("%" + book_title + "%"))
|
||||||
|
if publisher:
|
||||||
|
q = q.filter(db.Books.publishers.any(db.Publishers.name.ilike("%" + publisher + "%")))
|
||||||
for tag in include_tag_inputs:
|
for tag in include_tag_inputs:
|
||||||
q = q.filter(db.Books.tags.any(db.Tags.id == tag))
|
q = q.filter(db.Books.tags.any(db.Tags.id == tag))
|
||||||
for tag in exclude_tag_inputs:
|
for tag in exclude_tag_inputs:
|
||||||
|
Loading…
Reference in New Issue
Block a user