Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty Data on Whooshee_query even after calling reindex() #57

Open
highoncarbs opened this issue Sep 20, 2020 · 3 comments
Open

Empty Data on Whooshee_query even after calling reindex() #57

highoncarbs opened this issue Sep 20, 2020 · 3 comments

Comments

@highoncarbs
Copy link

highoncarbs commented Sep 20, 2020

@bkabrda Hi , I'm adding whooshee to an existing application. I tried calling whooshee.reindex() , but it returns empty data .

Here's my route

@bp.route('/search/<query>', methods=['GET'])
def search_product(query):
    
    data_schema = FinishedGoodsSchema(many=True)
    
    results = FinishedGoods.query.whooshee_search(query').order_by(FinishedGoods.id.desc())
    print(results)
    json_data = data_schema.dump(results)
    return jsonify(json_data)

Here's what the SQL prints out to ( only the last part )

 size_master_3.id = size_goods_child_1.size_id) ON finished_goods_child_1.id 
= size_goods_child_1.goods_id
WHERE null ORDER BY finished_goods.id DESC
@John-Oula
Copy link

has this been solved .Im getting the same issue?

@highoncarbs
Copy link
Author

Not sure , shifted to elasticsearch . Trust me, it's a much better option if you're building a web application. Cheers!

@pduebel
Copy link

pduebel commented Aug 25, 2023

This is very old now but I was facing the same problem and found the cause of the issue in my case.

The reindex method updates the index for the models that have been registered, this means that whooshee.reindex() needs to be called after any models have been registered. For me, I am defining my models in a separate file so my __init__.py file needed to look something like this:

app = Flask(__name__)
whooshee = Whooshee(app)

from app import models

with app.app_context():
    whooshee.reindex()

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

No branches or pull requests

3 participants