]:
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 = {
]:
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 = {
schema = whoosh.fields.Schema(
name=whoosh.fields.ID(stored=True),
table=whoosh.fields.STORED,
row_id=whoosh.fields.STORED,
schema = whoosh.fields.Schema(
name=whoosh.fields.ID(stored=True),
table=whoosh.fields.STORED,
row_id=whoosh.fields.STORED,
- language_id=whoosh.fields.STORED,
+ language=whoosh.fields.STORED,
+
+ # Whoosh 0.2 explodes when using a file-stored schema with no TEXT
+ # columns. Appease it
+ dummy=whoosh.fields.TEXT,
- # Construct a straight lookup index
- index = whoosh.index.Index(store, schema=schema, create=True)
+ index_directory = '/var/tmp/pokedex'
+ if not os.path.exists(index_directory):
+ os.mkdir(index_directory)
+ index = whoosh.index.create_in(index_directory, schema=schema)
extra_key = extra_key_func(row)
writer.add_document(name=extra_key, **row_key)
writer.commit()
extra_key = extra_key_func(row)
writer.add_document(name=extra_key, **row_key)
writer.commit()
+ # XXX GIHWEGREHKG
+ old__schema = whoosh.spelling.SpellChecker._schema
+ def new__schema(self):
+ schema = old__schema(self)
+ schema.add('dummy', whoosh.fields.TEXT)
+ return schema
+ whoosh.spelling.SpellChecker._schema = new__schema
+
# Construct and populate a spell-checker index. Quicker to do it all
# at once, as every call to add_* does a commit(), and those seem to be
# expensive
# Construct and populate a spell-checker index. Quicker to do it all
# at once, as every call to add_* does a commit(), and those seem to be
# expensive
# complications.
# The below is copied from SpellChecker.add_scored_words without the check
# for isalpha(). XXX get whoosh patched to make this unnecessary!
# complications.
# The below is copied from SpellChecker.add_scored_words without the check
# for isalpha(). XXX get whoosh patched to make this unnecessary!
for word in speller_entries:
fields = {"word": word, "score": 1}
for size in xrange(speller.mingram, speller.maxgram + 1):
for word in speller_entries:
fields = {"word": word, "score": 1}
for size in xrange(speller.mingram, speller.maxgram + 1):
# 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()
# 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()