Novak Djokovic secured a challenging victory against Aleksandar Kovacevic at Indian Wells, marking his first fourth-round appearance since 2017.