I'm currently trying to make a query where I can search for a specific String so it can display all the data associated with that string and similars.
What I've managed so far is: Query query = mDatabaseRef.orderByChild("name").startAt(s).endAt(s + "\uf8ff");
s here is the user input on an EditText field, sent from here this listener:
editTextSearch.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if(!s.toString().isEmpty()){
search(s.toString());
}
else search("");
}
});
And what this does is simply display all the results similar to the string written:
Example: I query for "Te" and I have 3 fields which are named the following: "Test" "Test Edited" "Edited Test" The query will then display me "Test" and "Test Edited" but not "Edited Test" If i search for "Edited" I get "Edited Test" but not the other one also named "Edited".
Is there a way to make it search for the value on the entire string? Also is there a way to make it so that capslocked words do not matter to the query? Say I have "Test" and "test" and i search for "t" can i make it so that it displays both instead of just "test"?