Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

没有返回结果 #16

Open
peichenzhong opened this issue Jan 6, 2019 · 0 comments
Open

没有返回结果 #16

peichenzhong opened this issue Jan 6, 2019 · 0 comments

Comments

@peichenzhong
Copy link

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from whoosh.analysis import StemmingAnalyzer
import flask_whooshalchemyplus
import config
from datetime import datetime
app=Flask(name)
app.config.from_object(config)
db=SQLAlchemy(app)
app.config['WHOOSH_BASE'] = 'path/to/whoosh/base'
class BlogPost(db.Model):
tablename = 'blogpost'
searchable = ['title', 'content'] # these fields will be indexed by whoosh
analyzer = StemmingAnalyzer () # configure analyzer; defaults to
# StemmingAnalyzer if not specified

id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(100)) # Indexed fields are either String,
content = db.Column(db.Text) # Unicode, or Text
created = db.Column(db.DateTime, default=datetime.now)

flask_whooshalchemyplus.init_app(app)

db.drop_all()
db.create_all()
db.session.add(
BlogPost(title='My cool title', content='This is the first post.')
); db.session.commit()
@app.route('/')
def index():
results = BlogPost.query.whoosh_search('cool')
print(results.all())
print(results)
return 'jeiguo %s '%(results)

if name=='main':
app.run()

结果为
image

image

请问哪里错了 什么返回的结果为空

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant