I have a mysql database that stores mainly JSON objects. I am thinking of using Sphinx to search through it – but i was wondering how would i index and retrieve these json objects?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It would be wise to have a field in the database which contains the important text stored in the JSON object. If your JSON objects are books, I would store the title, author and publisher as plain text in a database field
search_textas you commit the JSON to the database.Your SQL Query for the indexer might look like this
I haven’t tested how Sphinx handles raw JSON, although it can strip HTML via the
html_strip = 1conf setting. If you wanted something REALLY dirty, you could strip punctuation and JavaScript syntax from the json field with a series of nested MySQL string REPLACE() functions at indexing time.But you wouldn’t want to do that would you?