one-2-many relationship in schema

21 views
Skip to first unread message

Michał Łowicki

unread,
Nov 7, 2011, 3:58:20 PM11/7/11
to who...@googlegroups.com
Hi!

I've such models:

Model A has foreign key to model B. Model B has field 'b'. Model B can have translations stored in model BTrans so there is one-2-many relationship between B and BTrans.

I now want to search for A's entries by translations. So when user enter something e.g. in polish I want to return appropriate entries from model A.

It's better to have fields in schema like:

b_pl
b_en_gb
b_ru

and so on or maybe one text field which contains all the translations? Or maybe some other solution? Thanks in advance!

--
BR,
Michał Łowicki

Matt Billenstein

unread,
Nov 9, 2011, 8:17:38 PM11/9/11
to who...@googlegroups.com
What about keeping a separate index for each translation? How big is your
data?

m
> MichaAA* AA*owicki
>
> --
> You received this message because you are subscribed to the Google Groups
> "Whoosh" group.
> To post to this group, send email to who...@googlegroups.com.
> To unsubscribe from this group, send email to
> whoosh+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/whoosh?hl=en.

--
Matt Billenstein
ma...@vazor.com
http://www.vazor.com/

Matt Chaput

unread,
Nov 9, 2011, 8:41:28 PM11/9/11
to who...@googlegroups.com
(There is a branch in the repo with "hierarchical documents" that could help here, but it isn't released yet.)

I haven't had to write a system like this, but I would say:

* If your users only need to be able to search in one language at a time, make A documents with separate fields b_pl, b_en_gb, etc., and switch the default language of the query parser to the language the user is searching in.

(You would also be able to compose mixed-language queries like "b_esl:grande b_en_gb:colour")

* If your users usually need to search in any language or mixed languages, index all translations in a single field.

Hope this helps,

Matt

Reply all
Reply to author
Forward
0 new messages