Applying Word Stemming in SearchView for fetch data from Firebase database
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.
How to filter FirebaseRecyclerOptions with SearchBar
I needed a query indeed as @Black Mamba said. I used something like this:
Query query;
if(!(searchTxt.isEmpty())) {
query = Ref.orderByChild("Surname").startAt(search).endAt(search + "\uf8ff");
}
else{
query = Ref;
}
and the setOnQueryTextListener:
if (searchBar != null) {
searchBar.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
firebaseSearch(newText);
return true;
}
});
The firebaseSearch Method retrieves the data from the database.
Related Topics
Android Sd Card Write Permission Using Saf (Storage Access Framework)
Differencebetween Src and Background of Imageview
Android - Multi-Line Linear Layout
How to Change Separator Color in Navigationview
What Is the Equivalent of Actionbar in Earlier Sdk Versions
How to Send a Simple Email Programmatically? (Exists a Simple Way to Do It)
How to Draw Road Directions Between Two Geocodes in Android Google Map V2
How to Display Border to Imageview
Android E/Parcel﹕ Class Not Found When Unmarshalling (Only on Samsung Tab3)
How to Change Package Name in Android Studio
Android Circular Determinate Progressbar
Detect If an App Is Installed from Play Store
How to Communicate Between Activities
Generating Google Map Release API Key
Android Opengl Es Transparent Background
Android Screen Size Hdpi, Ldpi, Mdpi
How to Give Everyone Access to Firestore Database, But Only via App