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 nanyang cai <ca...@gmail.com> on 2013/01/22 03:48:59 UTC

how to avoid DataImportHandler from interpreting "tinyint(1) unsigned" value as "Boolean" value?

Hi,

DIH is really handy. But I found it interpret "Tinyint(1) unsigned" values
as "Boolean" values. In my case, we have a column 'status tinyint(1)', who
could hold value of (0, 1, 2, 3);

My configuration as blow:
db-data-config.xml :

    <field column="status" name="status"  />

schema.xml:

     <field name="status" type="integer" indexed="true" stored="true"/>

But search results after indexing:

    <str name="status">false</str>

I think value 1, 2, 3 are all read as true, this is not I want.

I've googled, and this is not a new problem. One solution is to change the
column type to 'Tinyint(2)', but this is not allowed for some reason.

I hope I've missed some other ways, could you point me out? Thank you!

Re: how to avoid DataImportHandler from interpreting "tinyint(1) unsigned" value as "Boolean" value?

Posted by nanyang cai <ca...@gmail.com>.
Just add a config attribute `convertType="true"` in the db-data-config.xml
will solve my problem. like below:

    <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql:..."
user="root" password="root" batchSize="-1" convertType="true"/>

2013/1/22 nanyang cai <ca...@gmail.com>

> Hi,
>
> DIH is really handy. But I found it interpret "Tinyint(1) unsigned" values
> as "Boolean" values. In my case, we have a column 'status tinyint(1)', who
> could hold value of (0, 1, 2, 3);
>
> My configuration as blow:
> db-data-config.xml :
>
>     <field column="status" name="status"  />
>
> schema.xml:
>
>      <field name="status" type="integer" indexed="true" stored="true"/>
>
> But search results after indexing:
>
>     <str name="status">false</str>
>
> I think value 1, 2, 3 are all read as true, this is not I want.
>
> I've googled, and this is not a new problem. One solution is to change the
> column type to 'Tinyint(2)', but this is not allowed for some reason.
>
> I hope I've missed some other ways, could you point me out? Thank you!
>
>