I have a table “Email” with field “contents” where the data are stored as hash object. I want to do search in this table with parameter “email => a5his@gmail.com” where :email is key and “a5his@gmail.com” is value of a hash object.
Thanks in advance
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.
This search is going to be extremely inefficient. If you plan on doing lot of of searches for email, it might be prudent to add an indexed column to store the email in your table.
I am assuming
contentsis a text field to store a serialized Hash. The hashes are serialized using YAML format, which is in plain text. So you can perform the regular wild card searches on thecontentcolumn.Eg:
A hash as shown below
is serialized in to string
So you can write a simple matcher as follows:
If you are planning on querying several dynamic fields then,
Now you can use the new method as: