Forum: Ruby on Rails Activerecord and EAV with search

A07884cccdbf1761fe2af1da28cb19e5?d=identicon&s=25 "Павел Макаров" <metus.violarium@gmail.com> (Guest)
on 2013-10-30 08:52
(Received via mailing list)
Hello. Would somebody like to answer me on question or give some advice?

In my situation I have to use EAV-model (MySQL database) to deal with
dynamic attributes (for products: color, weight, height and etc.)
Model: Product, Option, Value

So, in this case I have relation: product has many options through
values.
It's okay, when I modify and print it.

But what is the best solution for search on them?
Because I have to have many inner joins with the same table - values
And each join should have own conditions, for example:

>     option_alias1.name = 'color' AND values_alias1.value = '100'
>     AND option_alias2.name = 'weight' AND values_alias2.value < '200'
>

So, I can't do it by join existing relation many times, because I
haven't
got access to aliases. Should I write raw sql queries or there is more
convenient way?

Thank you.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2013-10-30 14:24
(Received via mailing list)
On Wednesday, October 30, 2013 6:19:35 AM UTC, Павел Макаров wrote:
> But what is the best solution for search on them?
>

Do you have to use Mysql for the search side too? Something like
elasticsearch is good at searching over that sort of dataset.

Fred
A07884cccdbf1761fe2af1da28cb19e5?d=identicon&s=25 "Павел Макаров" <metus.violarium@gmail.com> (Guest)
on 2013-10-31 11:46
(Received via mailing list)
Unfortunatelly, yes, I am.

, 30  2013 ., 17:22:54 UTC+4  Frederick Cheung
:
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.