0

I am developing an activity to search content in the FirebaseDatabase. I want to use a Query to get the tuples which CONTAIN the string searchBoxInput. I have tried the code below but it only returns the tuplas which start witch searchBoxInput, not which CONTAIN

private EditText searchInputText;
String searchBoxInput = searchInputText.getText().toString();

final Query query = ref
                .orderByChild("title")
                .startAt(searchBoxInput)
                .endAt(searchBoxInput + "\uf8ff");

How can I do it? Thanks :)

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
esterrrsinH
  • 171
  • 2
  • 11
  • The Firebase database only support prefix queries: finding results that start with a certain string. It doesn't support "contains" queries, or many other full-text search types. See https://stackoverflow.com/questions/10559191/firebase-and-indexing-search – Frank van Puffelen Dec 02 '18 at 19:11
  • And What do you recommend me to make what I want? – esterrrsinH Dec 02 '18 at 19:26
  • 1
    The most common approach is to use a third-party search provider, either self-hosted (such as Elastic Search) or cloud-hosted (such as Algolia). For a sample for Elastic Search, see https://github.com/FirebaseExtended/flashlight For a general approach for a Algolia (on Cloud Firestore, the approach is very similar), see https://firebase.google.com/docs/firestore/solutions/search. – Frank van Puffelen Dec 02 '18 at 22:39

0 Answers0