Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search where field is hash for having set of key-value matches #119

Closed
sarunks opened this issue Feb 7, 2014 · 2 comments
Closed

Search where field is hash for having set of key-value matches #119

sarunks opened this issue Feb 7, 2014 · 2 comments

Comments

@sarunks
Copy link

sarunks commented Feb 7, 2014

I have a model with hash field. I want to search all documents in the model where key1 => value1, key2 => value2 of the hash field

@ankane
Copy link
Owner

ankane commented Feb 13, 2014

Unfortunately, there's no way to do nested queries right now. You could prefix element of the hash in your search data method.

def search_data
  search_data = attributes.to_hash
  # assume settings is the hash
  settings.each do |name, value|
    search_data["settings_#{name}"] = value
  end
  search_data
end

@ankane
Copy link
Owner

ankane commented Mar 5, 2014

Created a new issue for nested queries #145

@ankane ankane closed this as completed Mar 5, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Dec 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants