Reputation: 1247
I was trying to import data from into solr
User Field1 Field2 Field3
1 a b c
1 d e f
2 a b c
However I am having trouble organizing the fields. I defined multiValue=true
for fields 1, 2 and 3 but the imported document looked like
doc {
id: 1,
field1:[a,d],
field2:[b,e],
field3:[c,f]
}
This is not the expected result. What I wanted is
doc {
id: 1,
property:[a,b,c]
property:[d,e,f]
}
which means all related fields of the given id should be grouped into one entity.
How should I define my schema?
My current schema is like:
<Entity name="main">
field id
<SubEntity name="related">
field1
field2
field3
</SubEntitiy>
Upvotes: 0
Views: 86
Reputation: 696
You cannot achieve this just with the help of defining field, you will have to send the data to SOLR also in that way.
Definition should be as below
<field name="id" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="field1" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="field2" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="field3" type="string" indexed="true" stored="true" multiValued="true"/>
Doc to index the data should be as below
<add>
<doc>
<field name="id">1234</field>
<field name="field1">a</field>
<field name="field1">b</field>
<field name="field1">c</field>
<field name="field2">d</field>
<field name="field2">e</field>
<field name="field2">f</field>
<field name="field3">a</field>
<field name="field3">b</field>
<field name="field3">c</field>
</doc>
</add>
From your description, it looks like you have the correct schema config in place but what is missing is the way you index the data.
Upvotes: 0