cool

The only problem is that java.sql.Clob#getCharacterStream() is package
private and you have to use the oracle.sql.CLOB



On Tue, Dec 2, 2008 at 1:38 PM, Joel Karlsson <[EMAIL PROTECTED]> wrote:
> Thanks for your reply!
>
> I wrote such a transformer and now it seems to work perfectly. Here's the
> code for the transformer if anyone encounters the same problem, or if anyone
> want to improve it:
>
> import org.apache.solr.handler.dataimport.*;
> import oracle.sql.CLOB;
> import java.util.*;
> import java.io.*;
>
> public class ClobTransformer extends Transformer
> {
>    public Map<String, Object> transformRow(Map<String, Object> row, Context
> context)
>    {
>        List<Map<String, String>> fields = context.getAllEntityFields();
>        for (Map<String, String> field : fields)
>        {
>            String toString = field.get("toString");
>            if ("true".equals(toString))
>            {
>                String columnName = field.get("column");
>                CLOB clob = (CLOB)row.get(columnName);
>                if (clob != null)
>                {
>                    StringBuffer strOut = new StringBuffer();
>                    String app;
>                    try {
>                    BufferedReader br = new
> BufferedReader(clob.getCharacterStream());
>                    while ((app=br.readLine())!=null)
>                    strOut.append(app);
>                    } catch (Exception e) { e.printStackTrace(); }
>
>                    row.put(columnName, strOut.toString());
>                }
>            }
>        }
>        return row;
>
>    }
> }
>
> // Joel
>
> 2008/12/2 Noble Paul നോബിള്‍ नोब्ळ् <[EMAIL PROTECTED]>
>
>> Hi Joel,
>> DIH does not translate Clob automatically to text.
>>
>> We can open that as an issue.
>> meanwhile you can write a transformer of your own to read Clob and
>> convert to text.
>>
>> http://wiki.apache.org/solr/DataImportHandler#head-4756038c418ab3fa389efc822277a7a789d27688
>>
>>
>> On Tue, Dec 2, 2008 at 2:57 AM, Joel Karlsson <[EMAIL PROTECTED]>
>> wrote:
>> > Thanks for your reply!
>> >
>> > I'm already using the DataImportHandler for indexing. Do I still have to
>> > convert the Clob myself or are there any built-in functions that I've
>> > missed?
>> >
>> > // Joel
>> >
>> >
>> > 2008/12/1 Yonik Seeley <[EMAIL PROTECTED]>
>> >
>> >> If you are querying Oracle yourself and using something like SolrJ,
>> >> then you must convert the Clob yourself into a String representation.
>> >>
>> >> Also, did you look at Solr's DataImportHandler?
>> >>
>> >> -Yonik
>> >>
>> >> On Mon, Dec 1, 2008 at 3:11 PM, Joel Karlsson <[EMAIL PROTECTED]>
>> >> wrote:
>> >> > Hello everyone,
>> >> >
>> >> > I'm trying to index on an Oracle DB, but can't seem to find any built
>> in
>> >> > support for objects of type oracle.sql.Clob. The field I try to put
>> the
>> >> data
>> >> > into is of type text, but after indexing it only contains the
>> >> Clob-objects
>> >> > string representation, i.e. something like [EMAIL PROTECTED]
>> >> who
>> >> > knows how to get Solr to index the content of these objects rather
>> than
>> >> its
>> >> > string representation??
>> >> >
>> >> > Thanks in advance! // Joel
>> >> >
>> >>
>> >
>>
>>
>>
>> --
>> --Noble Paul
>>
>



-- 
--Noble Paul

Reply via email to