所以我想为我的模型添加一个非常简单的搜索栏。这是我的模型文件:
db = DAL('sqlite://storage.sqlite',
pool_size=1, check_reserved=['all'],
migrate_enabled=True, lazy_tables=True)
from gluon.tools import Auth
auth = Auth(db)
auth.define_tables(username=False, signature=False)
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
db.define_table('chat',
Field('me_from'),
Field('me_body', 'text'),
Field('me_html', 'text'),
)
STORE_TYPE = ['Department store', 'Discount store', 'Warehouse store', 'Hardware store', 'Boutique']
db.define_table('employee',
Field('first_name'),
Field('last_name'),
Field('store_name'),
Field('store_type', requires=IS_IN_SET(STORE_TYPE)),
Field('zip_code'),
auth.signature)
db.employee.first_name.requires = IS_NOT_EMPTY()
db.employee.last_name.requires = IS_NOT_EMPTY()
db.employee.store_name.requires = IS_NOT_EMPTY()
db.employee.store_type.requires = IS_NOT_EMPTY()
db.employee.zip_code.requires = IS_NOT_EMPTY()
我正在查看 web2py https://github.com/mdipierro/web2py-haystack的 hastack 插件。我不确定如何将 elasticsearch 与 haystack 集成,因为它未在支持的后端中列出。
我想从员工表中为字段 store_name、store_type、zip_code 创建可搜索索引。
我想创建一个单独的视图,例如默认/搜索,它只有一个包含这些字段的搜索栏。如果有人能告诉我如何做到这一点,那就太好了?另外请告诉我我需要在模型和视图中添加/更改什么。