You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.
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()
结果为
请问哪里错了 什么返回的结果为空
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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()
结果为
请问哪里错了 什么返回的结果为空
The text was updated successfully, but these errors were encountered: