问题
I need to fetch list of users from Firebase database using SeachView
or search dialog and I think word stemming will be best for my app.
Not asking for code but please tell me the alorigthm for it.
回答1:
To achieve what you want, you need to execute a query which should look like this:
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference usersRef = rootRef.child("users");
Query query = usersRef.orderByChild("name").equalTo(newText);
So everytime you create a search you should return a new query. So according to this, every time you want to filter on a new condition, you will need to:
Create a new query based on the new filter:
Query query = usersRef.orderByChild("name").equalTo(newText);
Attach a listener to this new created query.
Create a new adapter with the results of this new created query, or update the existing one using
notifydatasetchanged()
method.
来源:https://stackoverflow.com/questions/50682046/applying-word-stemming-in-searchview-for-fetch-data-from-firebase-database