Use the functions in qa-app-posts.php (Q2A 1.4 or later) which provide an easy interface for retrieving and creating posts, and take care of indexing for you.