Generally, you just have to bite the bullet and denormalize. Yes, it really runs counter to to your DB mindset <G>....
But before jumping that way, how many denormalized records are we talking here? 1M? 100M? 1B? Solr has (4.x) some join capability, but it makes a lousy general-purpose database. You might want to look at Function Queries as a way to boost results based on numeric fields. If you want a strict ordering, you're looking at sort, but note that sorts only work on a single-valued field. Best Erick On Tue, Jun 5, 2012 at 12:48 PM, naleiden <nalei...@gmail.com> wrote: > Hi, > > First off, I'm about a week into all things Solr, and still trying to figure > out how to fit my relational-shaped peg through a denormalized hole. Please > forgive my ignorance below :-D > > I have the need store a One-to-N type relationship, and perform a boost a > related field. > > Let's say I want to index a number of different types of candy, and also a > customer's preference for each type of candy (which I index/update when a > customer makes a purchase), and then boost by that preference on search. > > Here is my paired-down attempt at a denormalized schema: > > <! -- Common Fields -- > > <field name="id" type="string" indexed="true" stored="true" required="true" > /> > <field name="type" type="string" indexed="true" stored="true" > required="true" /> > > <! -- Fields for 'candy' -- > > <field name="name" type="text_general" indexed="true" stored="true"/> > <field name="description" type="text_general" indexed="true" stored="true"/> > > <! -- Fields for Customer-Candy Preference ('preference') -- > > <field name="user" type="integer" indexed="true" stored="true"> > <field name="candy" type="integer" indexed="true" stored="true"> > <field name="weight" type="integer" indexed="true" stored="true" > default="0"> > > I am indexing 'candy' and 'preferences' separately, and when indexing one, I > leave the fields of the other empty (with the exception of the required 'id' > and 'type'). > > Ignoring the query score, this is effectively what I'm looking to do in SQL: > > SELECT candy.id, candy.name, candy.description FROM candy > LEFT JOIN preference ON (preference.candy = candy.id AND preference.customer > = 'someCustomerID') > // Where some match is made on query against candy.name or candy.description > ORDER BY preference.weight DESC > > My questions are: > > 1.) Am I making any assumptions with respect to what are effectively > different document types in the schema that will not scale well? I don't > think I want to be duplicating each 'candy' entry for every customer, or > maybe that wouldn't be such a big deal in Solr. > > 2.) Can someone point me in the right direction on how to perform this type > of boost in a Solr query? > > Thanks in advance, > Nick > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Boost-by-Nested-Query-Join-Needed-tp3987818.html > Sent from the Solr - User mailing list archive at Nabble.com.