I search my database in firebase using the following code:

myRef = FirebaseDatabase.getInstance().getReference("Π Π΅Ρ†Π΅ΠΏΡ‚Ρ‹"); Query query_search = myRef.orderByChild("Π˜Π½Π³Ρ€ΠΈΠ΄ΠΈΠ΅Π½Ρ‚Ρ‹").startAt("Молоко, яблоки"); query_search.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { String value_name = dataSnapshot.child("Имя").getValue(String.class); text.setText(value_name); 

where text is a TextView object

As a result of the code execution, I want to get the Имя field of the recipe, which includes the ingredients Яблоки, молоко

The code is executed for the database with the following structure: enter image description here

For reasons I do not understand, after executing the code text - let, and value_name = null

How to fix it?

upd

enter image description here

  • if you want all recipes to be included in the sample, conditionally, apples and milk, your ingredients should be in the database each separately (many to many), and not in one line. Since you are now, you will be able to find only by the exact coincidence of the whole line, and not by individual necessary ingredients - pavlofff
  • @pavlofff I changed the structure of my database, you can see it in my question. The goal remains the same: The user chooses several ingredients, let it be for example the user chooses Sugar and Carrot and as a result should get Carrot Salad - Vlad Yulin

1 answer 1

startAt("Молоко, яблоки");

Here you need to write just like in the database, that is, ("Π―Π±Π»ΠΎΠΊΠΈ, ΠΌΠΎΠ»ΠΎΠΊΠΎ") . Change places.