why is my firebase firestore data search not working with words or sentences

search initializer,where i’ve initialize variable as string but the textquerylistener taking my search input as character, and i’m getting only the items which are title by a single character

searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {         @Override         public boolean onQueryTextSubmit(String s) {             searchData(s);             return false;         }          @Override         public boolean onQueryTextChange(String newText) {             searchData(newText);             return false;         }     }); 

search algorithm

    private void searchData(String text) {     pd.setTitle("Searching.....");     pd.show();     db.collection("Documents").whereEqualTo("search",text.toLowerCase())             .get()             .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {                 @Override                 public void onComplete(@NonNull Task<QuerySnapshot> task) {                    modelList.clear();                     pd.dismiss();                     for(DocumentSnapshot documentSnapshot : Objects.requireNonNull(task.getResult())){                         Model model = new Model(documentSnapshot.getString("id"),                                 documentSnapshot.getString("title"),                                 documentSnapshot.getString("description"));                         modelList.add(model);                     }                     adapter = new CustomAdapter(ActivityDocList.this,modelList);                     recyclerView.setAdapter(adapter);                  }             })             .addOnFailureListener(new OnFailureListener() {                 @Override                 public void onFailure(@NonNull Exception e) {                     pd.dismiss();                     Toast.makeText(ActivityDocList.this,e.getMessage(),Toast.LENGTH_SHORT).show();                 }             }); } 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.