# retrieve something from the index
indexed_tables = {}
for cls in [
+ tables.Ability,
+ tables.Item,
+ tables.Move,
tables.Pokemon,
+ tables.Type,
]:
indexed_tables[cls.__tablename__] = cls
# Dictionary of extra keys to file types of objects under, e.g. Pokémon can
# also be looked up purely by number
extra_keys = {
+ tables.Move: [
+ lambda row: u"move %d" % row.id,
+ ],
tables.Pokemon: [
lambda row: unicode(row.id),
],
speller_entries.append(name)
- for extra_key_func in extra_keys[cls]:
+ for extra_key_func in extra_keys.get(cls, []):
extra_key = extra_key_func(row)
writer.add_document(name=extra_key, **row_key)
# Look for exact name. A Term object does an exact match, so we don't have
# to worry about a query parser tripping on weird characters in the input
searcher = index.searcher()
- query = whoosh.query.Term('name', name)
+ query = whoosh.query.Term('name', name.lower())
results = searcher.search(query)
if not exact_only: