On Tuesday, 6 October 2015 13:54:40 UTC-4, Arvind Vyas wrote:
>
> My code is this 
> <Product id: 44, data: {:my_data=>{"1"=>"5", "2"=>"test", "3"=>"tes"}}, 
> view_cout: 1>
>
> How I can write code to search project from "my_data" key or value ?
>
> I have search and found there is one way by hstore we can achieve it ( 
> https://github.com/diogob/activerecord-postgres-hstore) but in this sense 
> I have to change current logic of storing data also I have to move the 
> current data to new fild if I use this.
>                         Is there any good way which take less changes or 
> if not then what should I do to create filter for it.
>

You might want to consider the Postgres JSON support - it will allow for 
queries deep into the data.

BUT you should first think hard about whether this should be a serialized 
field at all; one of the primary tradeoffs you make with serialized fields 
vs. storing the data broken out into related records is *searchability*. If 
you're going to be querying the values extensively, maybe an alternative 
approach within your DB is better - or perhaps even a secondary indexing 
system (Solr / ElasticSearch / etc).

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/f31e08f1-95b3-44af-b4d2-d19513aeb227%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to