How does Delete and Edit works in apache answer

Viewed 209

Hi I've created an application with the help of apache answer now what is happening My application already using some DB but as we know for apache answer we have to create an different db I've create the db and add the respective tables into it like question,answers,comments,revision site_info and config now what is happening. Earlier I've made this application to post the data only but now the requirements changed I've to edit and delete also inside of it .So, i'm deleting the data from both the DBs because related to my application .Now the data got removed from the DBs but when i put the same comment,question, answer I'm getting duplicate submission due to which i'm not able to post the same data after deletion and evertime i need to restart stop the engine of my application remove the cache.db file from it and then restart it practically it is not possible for every update, we need to stop -> remove -> restart .
How can i fix this issue?

2 Answers

You should avoid directly deleting records from the Apache Answer database. Apache Answer maintains relationships between questions, answers, comments, revisions, activities, and other records. It also uses a separate cache database.

When you manually delete records from MySQL, you bypass Apache Answer's application-level logic, including related record updates, status changes, and cache management. This can leave the application in an inconsistent state.

Recommended approach:

  1. Use Apache Answer REST APIs: Instead of deleting records directly from the database, use the built-in APIs:

    • Delete question: DELETE /answer/api/v1/question
    • Update question: PUT /answer/api/v1/question
    • Delete answer: DELETE /answer/api/v1/answer
    • Update answer: PUT /answer/api/v1/answer
    • Delete comment: DELETE /answer/api/v1/comment
    • Update comment: PUT /answer/api/v1/comment
  2. Understand soft deletion: Apache Answer maintains a status field for questions, answers, and comments. For example, status 10 represents deleted records. Deletion does not necessarily mean the database row is physically removed.

  3. Check cache management: Apache Answer uses a separate cache file, configured through data.cache.file_path in config.yaml. Deleting cache.db manually should not be your regular deletion strategy. Investigate whether the duplicate-submission error is caused by stale cache entries or another application-level validation.

  4. Keep both databases synchronized: If your application has its own database, perform updates and deletions through a controlled integration process. Use the Apache Answer API for its records and your own database operations for your application's records.

One important question:

Are you deleting records directly using SQL queries, or are you using Apache Answer's API to delete them?

If you are using direct SQL queries, I would recommend switching to the REST API first. If the duplicate-submission problem continues even after using the official API, it may indicate a cache invalidation issue or a bug worth reporting to the Apache Answer GitHub repository.

API documentation: https://answer.apache.org/docs/

GitHub issues: https://github.com/apache/answer/issues