You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by manju16832003 <ma...@gmail.com> on 2013/05/10 08:16:53 UTC
multiValue schema example
Hi,
I have two table to be indexed.
Table-1: Person [id,name,addr]
Table-2: Docs [id,doc_name,person_id]
Relationship is: One person can have many documents.
I would like to get json as follows
[ { "id" : "name", "address",["doc_id1", "doc_id2", "doc_id3,etc...."] }]
How would I configure this in Solr.
How would I write configure the queries in data-config.xml
I tried this way. Main query and there is sub-query that returns many rows
to main query.
<document name="example">
<entity name="person" dataSource="ds-person" query="SELECT
id,name,address,'documents' FROM Person">
<entity name="docs" dataSource="ds-person" query="SELECT id as
doc_id FROM docs WHERE person_id='${person.id}'">
</entity>
</entity>
</document>
This is how my schema.xml data filed configuration
<field name="id" type="int" indexed="true" stored="true" required="true"
multiValued="false" />
<field name="name" type="string" indexed="true" stored="true"
omitNorms="true"/>
<field name="address" type="string" indexed="true" stored="true"/>
<field name="documents" type="int" indexed="true" stored="true"
omitNorms="true" multiValued="true"/>
<field name="doc_id" type="int" indexed="true" stored="true"
omitNorms="true"/>
I couldn't succeed.
What is the way to achieve the above scenario.
Thanks in advance.
--
View this message in context: http://lucene.472066.n3.nabble.com/multiValue-schema-example-tp4062209.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: multiValued schema example (SOLVED)
Posted by manju16832003 <ma...@gmail.com>.
Hi All,
I managed to *solve* the issue I had posted earlier with respect to
multiValued.
Here is the Query suppose to configured this way in *data-config.xml *
Description: in the below, first query has associated table images. Each
person would have many images. Here the JSON/XML would return all the images
associated with the person in block.
<document name="manju">
<entity name="list" dataSource="manjudb" query="select
member_id,MemberName FROM member">
<entity name="imagelist" dataSource="manjudb" query="SELECT imagepath FROM
images WHERE member_id='${list.member_id}'">
</entity>
</entity>
</document>
and *schema.xml* for the above query fields looks like
<field name="member_id" type="int" indexed="true" stored="true"
required="true"/>
<field name="MemberName" type="string" indexed="true" stored="true"/>
<field name="imagepath" type="string" indexed="true" stored="true"
<b>multiValued="true"* />
Output:
"response": {
"numFound": 3,
"start": 0,
"docs": [
{
"MemberName": "Vettel",
"member_id": 1,
"_version_": 1434904021528739800
},
{
"MemberName": "Schumacher",
"member_id": 2,
"imagepath": [ //As you could see here that Three rows from the
table *images* returned as one JSON object.
"c:\\\\images\\etc\\test.jpg",
"c:\\\\images\\etc\\test211.jpg",
"c:\\\\images\\etc\\test2343434.jpg",
"C:\\\\manju"
],
"_version_": 1434904021541322800
},
{
"MemberName": "J.Button",
"member_id": 3,
"_version_": 1434904021543420000
}
]
}
}
Thanks
--
View this message in context: http://lucene.472066.n3.nabble.com/multiValued-schema-example-SOLVED-tp4062209p4062864.html
Sent from the Solr - User mailing list archive at Nabble.com.