I have a android app Search functionality with backend PHP & mysql.
Currently on user keypress I am sending request to server fetching the data. (Live Suggestion).
With every keypress I am inserting the user input to the server.
Problem Is at end of day, to see the statistics of what users searched for is very difficult because of redundant data like follows.
User Searching for: Apple
Mobile Sends the request to server on every key press as follows
- A
- Ap
- App
- Appl
Apple
Question is: How to remove records from mysql [1 to 4] and keep only [5]
Note: Keep the same live search (On Key Press) functionality in Mobile App.
Other Notes: App is using REST API sending data through HTTP POST At a time 1000's of users may search the app. [Last previous record may not always the part of same query]
I solved this problem by sending a Unique key of 12 Character length along with search query, at end of day i am cleaning the the queries by keeping the most recent record for each key