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 Edward Zhang <bn...@gmail.com> on 2008/03/06 07:55:34 UTC
Some problem with ShowFileRequestHandler
I want to programmatically retrieve the schema and the config from the
ShowFileRequestHandler. I encounter some trouble. There are CJK characters
in the xml files as follows:
> <!-- Field to use to determine and enforce document uniqueness.
> Unless this field is marked with required="false", it will be a
> required field
> -->
> <uniqueKey>记录号</uniqueKey>
>
But I get a confusing response from solr using "/admin/file/?file=schema.xml".
IE and firefox both report parse errors.I try "/admin/file/?file=
schema.x&contentType=text/plain" and I get the same result as follow:
> <!-- Field to use to determine and enforce document uniqueness.
> Unless this field is marked with required="false", it will be a
> required field
> -->
> <uniqueKey>?????/uniqueKey>
BTW: The xml files are encoded in UTF-8 and they work fine when I open these
files locally using IE. And I set tomcat's 8080 connector "URIEncoding"
argument "UTF-8" too.
So is there anything missing for me? Or is it a bug?
Every reply would be appreciated.
Re: Some problem with ShowFileRequestHandler
Posted by Edward Zhang <bn...@gmail.com>.
Oh,I am sorry, Ryan, I am afriad I made a mistake.
It doesn't work yet.When I deploy the new war, it looks like before.
I rewrite to "IOUtils.copy( content.getStream(), writer, "utf-8" )" and it
works fine again!
Re: Some problem with ShowFileRequestHandler
Posted by Edward Zhang <bn...@gmail.com>.
It wroks, and a request with
argument "&contentType=text/xml;charset=utf-8" required to show my CJK
characters in my config file.
Thanks, Ryan
On 3/7/08, Ryan McKinley <ry...@gmail.com> wrote:
>
> Thanks for pointing this out.
>
> In trunk, I changed the RawResponseWriter to use the Reader rather then
> the Stream -- this way, you should not have to specify the contentType
> to make it match the FileReader.
>
> Does this fix your issues?
>
> thanks
> ryan
>
>
> Edward Zhang wrote:
> > My workmate and me found a solution to this problem: it caused by
> > org.apache.solr.request.RawResponseWriter.
> > Solr required the config file encoded in UTF-8 by far. But when
> > RawResponseWriter put the byte stream to writer, it doesn't notice the
> > characters encoding.There may be some trouble when the xml file contain
> > CJK characters.
> >
> > So we add argument "utf-8" for method "IOUtils.copy" and we send the
> > request with "admin/file/?file=schema.xml&contentType=text/xml
> ;charset=utf-8",
> > it works!
> >
> > Am I right?
> >
> > May be method "IOUtils.copy( content.getStream(), writer)" keep default
> > encoding argument for more encoded config files support?
> >
> >
> >> public void write(Writer writer, SolrQueryRequest request,
> >> SolrQueryResponse response) throws IOException
> >> {
> >> Object obj = response.getValues().get( CONTENT );
> >> if( obj != null && (obj instanceof ContentStream ) ) {
> >> // copy the contents to the writer...
> >> ContentStream content = (ContentStream)obj;
> >> //IOUtils.copy( content.getStream(), writer);
> >> IOUtils.copy( content.getStream(), writer, "utf-8");
> >> }
> >> else {
> >> getBaseWriter( request ).write( writer, request, response );
> >> }
> >> }
> >>
> > On 3/6/08, Edward Zhang <bn...@gmail.com> wrote:
> >> I want to programmatically retrieve the schema and the config from the
> >> ShowFileRequestHandler. I encounter some trouble. There are CJK
> characters
> >> in the xml files as follows:
> >>
> >>
> >>> <!-- Field to use to determine and enforce document uniqueness.
> >>> Unless this field is marked with required="false", it will be a
> >>> required field
> >>> -->
> >>> <uniqueKey>记录号</uniqueKey>
> >>>
> >> But I get a confusing response from solr using "/admin/file/?file=
> >> schema.xml". IE and firefox both report parse errors.I try
> >> "/admin/file/?file=schema.x&contentType=text/plain" and I get the same
> >> result as follow:
> >>
> >>
> >>> <!-- Field to use to determine and enforce document uniqueness.
> >>> Unless this field is marked with required="false", it will be a
> >>> required field
> >>> -->
> >>> <uniqueKey>?????/uniqueKey>
> >>
> >> BTW: The xml files are encoded in UTF-8 and they work fine when I open
> >> these files locally using IE. And I set tomcat's 8080 connector
> >> "URIEncoding" argument "UTF-8" too.
> >> So is there anything missing for me? Or is it a bug?
> >>
> >> Every reply would be appreciated.
> >>
> >>
> >>
> >>
> >>
>
>
Re: Some problem with ShowFileRequestHandler
Posted by Ryan McKinley <ry...@gmail.com>.
Thanks for pointing this out.
In trunk, I changed the RawResponseWriter to use the Reader rather then
the Stream -- this way, you should not have to specify the contentType
to make it match the FileReader.
Does this fix your issues?
thanks
ryan
Edward Zhang wrote:
> My workmate and me found a solution to this problem: it caused by
> org.apache.solr.request.RawResponseWriter.
> Solr required the config file encoded in UTF-8 by far. But when
> RawResponseWriter put the byte stream to writer, it doesn't notice the
> characters encoding.There may be some trouble when the xml file contain
> CJK characters.
>
> So we add argument "utf-8" for method "IOUtils.copy" and we send the
> request with "admin/file/?file=schema.xml&contentType=text/xml;charset=utf-8",
> it works!
>
> Am I right?
>
> May be method "IOUtils.copy( content.getStream(), writer)" keep default
> encoding argument for more encoded config files support?
>
>
>> public void write(Writer writer, SolrQueryRequest request,
>> SolrQueryResponse response) throws IOException
>> {
>> Object obj = response.getValues().get( CONTENT );
>> if( obj != null && (obj instanceof ContentStream ) ) {
>> // copy the contents to the writer...
>> ContentStream content = (ContentStream)obj;
>> //IOUtils.copy( content.getStream(), writer);
>> IOUtils.copy( content.getStream(), writer, "utf-8");
>> }
>> else {
>> getBaseWriter( request ).write( writer, request, response );
>> }
>> }
>>
> On 3/6/08, Edward Zhang <bn...@gmail.com> wrote:
>> I want to programmatically retrieve the schema and the config from the
>> ShowFileRequestHandler. I encounter some trouble. There are CJK characters
>> in the xml files as follows:
>>
>>
>>> <!-- Field to use to determine and enforce document uniqueness.
>>> Unless this field is marked with required="false", it will be a
>>> required field
>>> -->
>>> <uniqueKey>记录号</uniqueKey>
>>>
>> But I get a confusing response from solr using "/admin/file/?file=
>> schema.xml". IE and firefox both report parse errors.I try
>> "/admin/file/?file=schema.x&contentType=text/plain" and I get the same
>> result as follow:
>>
>>
>>> <!-- Field to use to determine and enforce document uniqueness.
>>> Unless this field is marked with required="false", it will be a
>>> required field
>>> -->
>>> <uniqueKey>?????/uniqueKey>
>>
>> BTW: The xml files are encoded in UTF-8 and they work fine when I open
>> these files locally using IE. And I set tomcat's 8080 connector
>> "URIEncoding" argument "UTF-8" too.
>> So is there anything missing for me? Or is it a bug?
>>
>> Every reply would be appreciated.
>>
>>
>>
>>
>>
Re: Some problem with ShowFileRequestHandler
Posted by Edward Zhang <bn...@gmail.com>.
My workmate and me found a solution to this problem: it caused by
org.apache.solr.request.RawResponseWriter.
Solr required the config file encoded in UTF-8 by far. But when
RawResponseWriter put the byte stream to writer, it doesn't notice the
characters encoding.There may be some trouble when the xml file contain
CJK characters.
So we add argument "utf-8" for method "IOUtils.copy" and we send the
request with "admin/file/?file=schema.xml&contentType=text/xml;charset=utf-8",
it works!
Am I right?
May be method "IOUtils.copy( content.getStream(), writer)" keep default
encoding argument for more encoded config files support?
> public void write(Writer writer, SolrQueryRequest request,
> SolrQueryResponse response) throws IOException
> {
> Object obj = response.getValues().get( CONTENT );
> if( obj != null && (obj instanceof ContentStream ) ) {
> // copy the contents to the writer...
> ContentStream content = (ContentStream)obj;
> //IOUtils.copy( content.getStream(), writer);
> IOUtils.copy( content.getStream(), writer, "utf-8");
> }
> else {
> getBaseWriter( request ).write( writer, request, response );
> }
> }
>
On 3/6/08, Edward Zhang <bn...@gmail.com> wrote:
>
> I want to programmatically retrieve the schema and the config from the
> ShowFileRequestHandler. I encounter some trouble. There are CJK characters
> in the xml files as follows:
>
>
> > <!-- Field to use to determine and enforce document uniqueness.
> > Unless this field is marked with required="false", it will be a
> > required field
> > -->
> > <uniqueKey>记录号</uniqueKey>
> >
>
> But I get a confusing response from solr using "/admin/file/?file=
> schema.xml". IE and firefox both report parse errors.I try
> "/admin/file/?file=schema.x&contentType=text/plain" and I get the same
> result as follow:
>
>
> > <!-- Field to use to determine and enforce document uniqueness.
> > Unless this field is marked with required="false", it will be a
> > required field
> > -->
> > <uniqueKey>?????/uniqueKey>
>
>
> BTW: The xml files are encoded in UTF-8 and they work fine when I open
> these files locally using IE. And I set tomcat's 8080 connector
> "URIEncoding" argument "UTF-8" too.
> So is there anything missing for me? Or is it a bug?
>
> Every reply would be appreciated.
>
>
>
>
>