Firestore Java Get fields ​of documents within collections without knowing the name of them

I’m programming an activity that through firebaserecyclerview gets all posts of an user from the following firestore structure:

--- posts (collection)
         |
         --- uid (documents)
              |
              --- userPosts (collection)
                    |
                    --- postId (documents)
                    |     |
                    |     --- title: "Post Title"
                    |     |
                    |     --- date: September 03, 2018 at 6:16:58 PM UTC+3
                    |
                    --- postId (documents)
                          |
                          --- title: "Post Title"
                          |
                          --- date: 08/06/2021
                          |
                          --- description: "this is the description of the post"
                          [...etc]

This is my incorrect query sketch:

Query query = FirebaseFirestore.getInstance()
        .collection("post").document(uidVisit).collection("userPosts")
        .limit(1000);

Obviously, the above query is wrong for what I want to get, because that query stops at selecting the contents of userpost which are nothing more than the ids of the posts that I actually have to fetch:

effect of the previous query

Instead, I want to take all the contents of the various user posts but the only problem is that I do not know the post id (because they are all different). Is there a way then to get the posts from that firestore structure that I inserted at the beginning of the post? I hope I have made you understand my problem

In case it can help you, I leave my complete code:

Full Code:

EditText searchEt;
    TextView ustxt;


    private RecyclerView findUsersList;  //fidnfirendlist

    private String str = "", uidVisit = "";
    private DatabaseReference usersRef;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_visualizza_post);
        overridePendingTransition(0, 0);

        Intent intent = getIntent();
        uidVisit = intent.getStringExtra("uidVisit");

        findUsersList = findViewById(R.id.usersSearched);

        searchEt = findViewById(R.id.txt_ricerca);
        ustxt = findViewById(R.id.name_text);
        findUsersList.setLayoutManager(new LinearLayoutManager(getApplicationContext()));

    }


    @Override
    protected void onStart() {
        super.onStart();

        Query query = FirebaseFirestore.getInstance()
                .collection("post").document(uidVisit).collection("userPosts")
                //.orderby
                .limit(50);

        FirestoreRecyclerOptions<GetInfoPost> options = new FirestoreRecyclerOptions.Builder<GetInfoPost>()
                .setQuery(query, GetInfoPost.class)
                .build();

        FirestoreRecyclerAdapter<GetInfoPost, FindFriendsViewHolder> firestoreRecyclerAdapter = new FirestoreRecyclerAdapter<GetInfoPost, FindFriendsViewHolder>(options) {
            @Override
            protected void onBindViewHolder(@NonNull FindFriendsViewHolder holder, int position, @NonNull GetInfoPost model) {
                holder.txtTitoloInPost.setText(model.getTitle());
                holder.txtData.setText(model.getdate());
                Picasso.get().load(model.getUrlImage()).into(holder.imgPost);
                holder.txtDescrizione.setText(model.getDescription());
                holder.txtTag.setText(model.getGenre());
               // holder.txtLikenmb.setText(model.getLike());
            }

            @NonNull
            @Override
            public FindFriendsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

                View view = LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.post, parent, false);

                return new FindFriendsViewHolder(view);
            }
        };

        findUsersList.setAdapter(firestoreRecyclerAdapter);
        firestoreRecyclerAdapter.startListening();






    }

    public static class FindFriendsViewHolder extends RecyclerView.ViewHolder {

        TextView nameInPost, txtData, txtTag, txtTitoloInPost, txtLikenmb, txtDescrizione;
        ImageView img_profinPost, imgPost;
        RelativeLayout cardView;



        public FindFriendsViewHolder(@NonNull View itemView) {
            super(itemView);

            nameInPost = itemView.findViewById(R.id.nameInPost);
            txtData = itemView.findViewById(R.id.txtData);
            txtTag = itemView.findViewById(R.id.txtTag);
            txtTitoloInPost = itemView.findViewById(R.id.txtTitoloInPost);
            txtLikenmb = itemView.findViewById(R.id.txtLikenmb);
            txtDescrizione = itemView.findViewById(R.id.txtDescrizione);

            img_profinPost = itemView.findViewById(R.id.img_profinPost);
            imgPost = itemView.findViewById(R.id.imgPost);


            cardView = itemView.findViewById(R.id.card_viewR);

        }
    }

GetInfoPost class:

package com.conta.pophome;

public class GetInfoPost {

    String title, urlImage, genre, valutation, date, description, like;

    public GetInfoPost() {
    }

    public GetInfoPost( String title, String urlImage, String genre, String valutation, String date, String description, String like) {
        this.title = title;
        this.urlImage = urlImage;
        this.genre = genre;
        this.valutation = valutation;
        this.date = date;
        this.description = description;
    }

    public String getLike() {
        return like;
    }

    public void setLike(String title) {
        this.like = like;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String title) {
        this.description = description;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getUrlImage() {
        return urlImage;
    }

    public void setUrlImage(String urlImage) {
        this.urlImage = urlImage;
    }

    public String getGenre() {
        return genre;
    }

    public void setGenre(String genre) {
        this.genre = genre;
    }

    public String getValutation() {
        return valutation;
    }

    public void setValutation(String valutation) {
        this.valutation = valutation;
    }

    public String getdate() {
        return date;
    }

    public void setdate(String date) {
        date = date;
    }
}

Updated query:

Query query = FirebaseFirestore.getInstance()
                .collection("post/" + uidVisit + "/userPosts")
                .limit(1000);

Answer

You can call document.getId() to get document id.

Query query = FirebaseFirestore.getInstance()
                .collection("post").document(uidVisit).collection("userPosts")
                //.orderby
                .limit(50);

  
           query.get()
            .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                @Override
                public void onComplete(@NonNull Task<QuerySnapshot> task) {
                    if (task.isSuccessful()) {
                        for (QueryDocumentSnapshot document : task.getResult()) {
                            Log.d(TAG, document.getId() + " => " + document.getData());
                        }
                    } else {
                        Log.d(TAG, "Error getting documents: ", task.getException());
                    }
                }
            });