returns nothing no mater what keyword
See original GitHub issueHi, I just modified my code following the instruction of QuickStart and Config, like this
@course.route("/search")
def w_search():
keyword = request.args.get('q')
results = Course.query.msearch(keyword,fields=['title']).first()
return redirect(url_for('course.classes', id=results.id))
However it returns nothing no mater what keywords
did I miss some other configurations?
actually, I know nothing about the role of Create_index
Thanks a Lot For Your Help!!!
>>> Course.query.msearch('asdf',fields=['title']).all()
[]
>>> Course.query.filter_by(title='asdf').all()
[<Course u'asdf'>]
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
The pass Statement: How to Do Nothing in Python
In Python, the pass keyword is an entire statement in itself. This statement doesn't do anything: it's discarded during the byte-compile phase.
Read more >Is there a way to return literally nothing in python?
There is no such thing as "returning nothing" in Python. Every function returns some value (unless it raises an exception).
Read more >How to Use the return Keyword in Java - HubSpot Blog
The return keyword stops the execution of a function and returns the desired output. Even if there's no value to return, it will...
Read more >Halt! In the name of C++; or why C++ functions don't need a ...
tl;dr: C++ functions do not require a return keyword in them to be well-formed and compile, though it will likely cause undefined behaviour....
Read more >documentation of `return nothing` in Manual/Functions?
I guess coming from C/C++, that having return without an argument mean “return nothing” seems totally natural. I agree that it seems natural...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@AdamGold
current_user
isn’t model instance, you should usecurrent_user._get_current_object()
Thanks for reply @honmaple! I’m new to full-text search space, so please be adaptive on my idiocy.
If I understand correctly, analyzer returns tokens and if token (or their variable sum) is not a whole query, then search fails?
Example in your last example, say query was
ch
, while non of tokens have exact token:Then what added benefit is there over using:
results = <Model>.query.filter(<Model>.<column>.ilike(f'%{q}%')).all()
- whereq
is a query.which is case insensitive search for substrings in Model column. Is it performance? Or am I misunderstanding tokenization on whoosh part?