When in doubt... flatten.
Seriously.
Multivalued fields are an extremely useful feature of Solr, but they MUST be
used in moderation and with careful discipline. They simply are not the kind
of "get out of (data modeling) jail for free and pass (data modeling) Go"
card that too many people fantasize them as being.
I'm sure that there are any number of ways to model this stuff, but we here
still don't have enough information to know what you are really need.
As usual, start with the queries - what will typical queries for this index
want to look like, and what kind of information would the application expect
in the response. Work backwards from their to formulate a workable data
model.
Any time you think you need to "coordinate" data implies that either you
will need a Solr document in which each of the items is flat or at most one
is multivalued, or that your app will need to simulate a join between two
separate Solr collections. Or... figure some hack for combining the values
into a single string value in Solr that the app can easily pick apart if
needed (e.g., feature name and description concatenated with a delimiter
between them), maybe in conjunction with a copyField of the raw,
uncoordinated multvalued fields for easy query access.
-- Jack Krupansky
-----Original Message-----
From: Mysurf Mail
Sent: Sunday, June 23, 2013 4:37 AM
To: solr-user@lucene.apache.org
Subject: Re: modeling multiple values on 1:n connection
Thanks for your comment.
What I need is to model it so that i can connect between the featureName
and the feature description of the.
Currently if item has 3 features I get two list - each three elements long.
But then I need to correlate them.
On Sun, Jun 23, 2013 at 9:25 AM, Gora Mohanty <g...@mimirtech.com> wrote:
On 23 June 2013 01:31, Mysurf Mail <stammail...@gmail.com> wrote:
> I try to model my db using
> this<http://wiki.apache.org/solr/DataImportHandler#Full_Import_Example
>example
> from solr wiki.
>
> I have a table called item and a table called features with
> id,featureName,description
>
> here is the updated xml (added featureName)
>
> <dataConfig>
> <dataSource driver="org.hsqldb.jdbcDriver"
> url="jdbc:hsqldb:/temp/example/ex" user="sa" />
> <document>
> <entity name="item" query="select * from item">
> <entity name="feature" query="select description,
> featureName as features from feature where item_id='${item.ID}'"/>
> </entity>
> </document>
>
>
> Now I get two lists in the xml element
>
> <doc>
> <arr name="featureName">
> <str>number of miles in every direction the universal cataclysm was
> gathering</str> <str>All around the Restaurant people and things relaxed
> and chatted. The</str> <str>- Do we have... - he put up a hand to hold
back
> the cheers, - Do we</str> </arr> <arr name="description">
> <str>to a stupefying climax. Glancing at his watch, Max returned to the
> stage</str> <str>air was filled with talk of this and that, and with the
> mingled scents of</str> <str>have a party here from the Zansellquasure
> Flamarion Bridge Club from</str>
> </arr>.
> </doc>
> But I would like to see the list together (using xml attributes) so that
I
> dont have to join the values.
> Is it possible?
While it is not clear to me what you are asking, I am
guessing that you do not want the featureName and
description fields to appear as arrays. This is happening
because you have defined them as multi-valued in the
Solr schema. What exactly do you want to "join" here?
Regards,
Gora