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 Romi <ro...@gmail.com> on 2011/05/26 09:29:30 UTC
UniqueKey field in schema.xml
suppose I have two tables in database, say product table and customer table.i
want to make (productID,customerID) a uniqueKey for my indexing document.
how can i achieve this.
-----
Romi
--
View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2987807.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: UniqueKey field in schema.xml
Posted by Romi <ro...@gmail.com>.
Thanks a lot :)...finally i made it, template transformer is doing exactly
what i wanted to do. :) :)
-----
Romi
--
View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2988608.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: UniqueKey field in schema.xml
Posted by Romi <ro...@gmail.com>.
Stefen, as u can see
<entity name="torder" query="select
UID_PK,creationDate,email,confirmationCode from torder ">
<field column="creationDate" name="date" />
<entity name="torderattribute"
transformer="TemplateTransformer" query="select UID_PK from torderattribute
where orderUID='${torder.UID_PK}'">
<field column="UID_PK"
<h3>template="{torder.UID_PK},${torderattribute.UID_PK}
" />
</entity>
</entity>
orderUID is a foreignkey for the table torderattribue which maps to
UID_PK(pk) of torder.
when i run the query "select UID_PK from torderattribute where
orderUID='${torder.UID_PK}'" this should fetch multiple rows ,because
corredponding to one orderUID there are multiple rows.
but it is not.
to make it more clear consider this:
torder:
UID_PK(primary key)
120
121
122
torderattribute
UID_PK(primary key) orderUID
86 120
87 120
89 121
90 121
91 121
and in my search result i got only(120,86),(121,89). i am missing 3 values
in torderattribute. why so , please explain.
Thanks
Romi.
-----
Romi
--
View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2988774.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: UniqueKey field in schema.xml
Posted by Romi <ro...@gmail.com>.
first, you're missing a $ Sign for the first Variable.
second, why not just <field column="ID" .. /> ? The <field>-Tag has no
ID, in case you're using the TemplateTransformer.
I got my solution..thanks for it.
but after looking your this reply..please make it clear:
UID_PK is a column in my database table torderattribute, then I it is
mandatory to map it in schema.xml,that is why i use <field column="UID_PK"
name= ID ../>
then how can i just use <field column="ID" .. />
-----
Romi
--
View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2988635.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: UniqueKey field in schema.xml
Posted by Stefan Matheis <ma...@googlemail.com>.
Romi,
first, you're missing a $ Sign for the first Variable.
second, why not just <field column="ID" .. /> ? The <field>-Tag has no
ID, in case you're using the TemplateTransformer.
Regards
Stefan
Am 26.05.2011 14:16, schrieb Romi:
> I tried it as :
> <entity name="torder" query="select
> UID_PK,creationDate,email,confirmationCode from torder ">
> <field column="creationDate" name="date" />
> <entity name="torderattribute" transformer="TemplateTransformer"
> query="select UID_PK from torderattribute where
> orderUID='${torder.UID_PK}'">
> <field column="UID_PK"
> <h3>template="{torder.UID_PK},${torderattribute.UID_PK}
> " />
> </entity>
> </entity>
>
>
>
> But i suppose it is not correct because here i am not mapping UID_PK of
> torderattribute to any of field in schema.xml. can i add like this:
> <field column="UID_PK" name= ID
> template="{torder.UID_PK},${torderattribute.UID_PK}" />
>
>
> where ID is a field in schema.xml and it is UniqueKey.
>
> -----
> Romi
> --
> View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2988484.html
> Sent from the Solr - User mailing list archive at Nabble.com.
Re: UniqueKey field in schema.xml
Posted by Romi <ro...@gmail.com>.
I tried it as :
<entity name="torder" query="select
UID_PK,creationDate,email,confirmationCode from torder ">
<field column="creationDate" name="date" />
<entity name="torderattribute" transformer="TemplateTransformer"
query="select UID_PK from torderattribute where
orderUID='${torder.UID_PK}'">
<field column="UID_PK"
<h3>template="{torder.UID_PK},${torderattribute.UID_PK}
" />
</entity>
</entity>
But i suppose it is not correct because here i am not mapping UID_PK of
torderattribute to any of field in schema.xml. can i add like this:
<field column="UID_PK" name= ID
template="{torder.UID_PK},${torderattribute.UID_PK}" />
where ID is a field in schema.xml and it is UniqueKey.
-----
Romi
--
View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2988484.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: UniqueKey field in schema.xml
Posted by Stefan Matheis <ma...@googlemail.com>.
Romi,
then you want to use the
http://wiki.apache.org/solr/DataImportHandler#TemplateTransformer ? :)
Regards
Stefan
Am 26.05.2011 13:17, schrieb Romi:
> i might have misspelled the question.
> this is the entry in my db-data-config.xml file:
> <entity name="torder" query="select
> UID_PK,creationDate,email,confirmationCode from torder ">
> <field column="creationDate" name="date" />
> <entity name="torderattribute" query="select UID_PK from torderattribute
> where orderUID='${torder.UID_PK}'">
> <field column="UID_PK" name="UID" />
> </entity>
> </entity>
>
>
> now i want combine UID_PK and UID for the uniqueKey of my indexing documet.
> i want to know how can i achieve this through schema.xml
>
> Thanks
> Romi
>
> -----
> Romi
> --
> View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2988323.html
> Sent from the Solr - User mailing list archive at Nabble.com.
Re: UniqueKey field in schema.xml
Posted by Romi <ro...@gmail.com>.
i might have misspelled the question.
this is the entry in my db-data-config.xml file:
<entity name="torder" query="select
UID_PK,creationDate,email,confirmationCode from torder ">
<field column="creationDate" name="date" />
<entity name="torderattribute" query="select UID_PK from torderattribute
where orderUID='${torder.UID_PK}'">
<field column="UID_PK" name="UID" />
</entity>
</entity>
now i want combine UID_PK and UID for the uniqueKey of my indexing documet.
i want to know how can i achieve this through schema.xml
Thanks
Romi
-----
Romi
--
View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2988323.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: UniqueKey field in schema.xml
Posted by François Schiettecatte <fs...@gmail.com>.
Here is some code:
------
final String key1 = "1";
final String key2 = "2";
final String masterKey = key1 + ":" + key2;
------
You need to combine the keys *before* you send them to Solr.
François
On May 26, 2011, at 7:02 AM, Romi wrote:
> I am not getting how can i combine two keys in to a single string using some
> delimiter
>
> -----
> Romi
> --
> View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2988284.html
> Sent from the Solr - User mailing list archive at Nabble.com.
Re: UniqueKey field in schema.xml
Posted by Romi <ro...@gmail.com>.
I am not getting how can i combine two keys in to a single string using some
delimiter
-----
Romi
--
View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2988284.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: UniqueKey field in schema.xml
Posted by François Schiettecatte <fs...@gmail.com>.
You concatenate the two keys into a single string, with some sort of delimiter between the two keys.
François
On May 26, 2011, at 6:05 AM, Romi wrote:
> what do you mean by combine two fields customerID and ProductId.
> what i tried is
> 1. make both fields unique but it doesnot server my purpose
> 2. make a new field ID and copy both customerID , ProductId into ID using
> CopyField and now make ID as uniqueKey
> but i got a error saying: Document specifies multiple unique ids
>
> -----
> Romi
> --
> View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2988168.html
> Sent from the Solr - User mailing list archive at Nabble.com.
Re: UniqueKey field in schema.xml
Posted by Romi <ro...@gmail.com>.
what do you mean by combine two fields customerID and ProductId.
what i tried is
1. make both fields unique but it doesnot server my purpose
2. make a new field ID and copy both customerID , ProductId into ID using
CopyField and now make ID as uniqueKey
but i got a error saying: Document specifies multiple unique ids
-----
Romi
--
View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2988168.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: UniqueKey field in schema.xml
Posted by pravesh <su...@yahoo.com>.
Create a new unique field for this purpose, like, "myUniqueField", then, just
combine (product-id+cust-id) and post it to this new field.
--
View this message in context: http://lucene.472066.n3.nabble.com/UniqueKey-field-in-schema-xml-tp2987807p2988098.html
Sent from the Solr - User mailing list archive at Nabble.com.