Selecting only the items in API response

Suppose I have two content types: a book index and books. Book index has two fields, genre and links of book entries. Now I fetched the book index using query content_type=book_index and I want to pass {genre: book_genre, ids:[]} to the frontend, where user can then select with book to see. If I do cdaArray.entries(), all entries including books will be returned. I just want the id of the books. So ideally the entries should just have one book index entry, and I can getFields(links) and iterate them to get list of ids. But now I have all entries. I don’t want to differentiate them. Can anyone propose a solution in Java? Thanks