question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

returns nothing no mater what keyword

See original GitHub issue

Hi, 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:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
honmaplecommented, Jun 13, 2019

@AdamGold current_user isn’t model instance, you should use current_user._get_current_object()

0reactions
yomajocommented, Aug 2, 2022

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:

print([token.text for token in ana("Opentech")])
# ['Ope', 'pen', 'ent', 'nte', 'tec', 'ech']

Then what added benefit is there over using: results = <Model>.query.filter(<Model>.<column>.ilike(f'%{q}%')).all() - where q is a query.

which is case insensitive search for substrings in Model column. Is it performance? Or am I misunderstanding tokenization on whoosh part?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found