SOLR-1595: use utf8 in streaming solrj client

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@883566 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2009-11-24 01:42:40 +00:00
parent c812e9fc5b
commit 73fe358140
3 changed files with 17 additions and 7 deletions

View File

@ -86,7 +86,12 @@ Bug Fixes
or the close of a core resulted in a warning:
"SEVERE: SolrIndexWriter was not closed prior to finalize()" although
there were no other consequences. (yonik)
* SOLR-1595: StreamingUpdateSolrServer used the patform default character
set when streaming updates, rather than using UTF-8 as the HTTP headers
indicated, leading to an encoding mismatch. (hossman, yonik)
didn't specify the character set creating OutputStreamWriter
Other Changes

View File

@ -90,7 +90,7 @@ public class StreamingUpdateSolrServer extends CommonsHttpSolrServer
public void writeRequest(OutputStream out) throws IOException {
try {
OutputStreamWriter writer = new OutputStreamWriter( out );
OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
writer.append( "<stream>" ); // can be anything...
UpdateRequest req = queue.poll( 250, TimeUnit.MILLISECONDS );
while( req != null ) {

View File

@ -175,7 +175,7 @@ abstract public class SolrExampleTests extends SolrExampleTestBase
SolrInputDocument doc2 = new SolrInputDocument();
doc2.addField( "id", "id2", 1.0f );
doc2.addField( "name", "doc2", 1.0f );
doc2.addField( "name", "h\u1234llo", 1.0f );
doc2.addField( "price", 20 );
Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
@ -191,7 +191,7 @@ abstract public class SolrExampleTests extends SolrExampleTestBase
query.addSortField( "price", SolrQuery.ORDER.asc );
QueryResponse rsp = server.query( query );
Assert.assertEquals( 2, rsp.getResults().getNumFound() );
assertEquals( 2, rsp.getResults().getNumFound() );
System.out.println( rsp.getResults() );
// Now do it again
@ -199,9 +199,14 @@ abstract public class SolrExampleTests extends SolrExampleTestBase
server.commit();
rsp = server.query( query );
Assert.assertEquals( 2, rsp.getResults().getNumFound() );
System.out.println( rsp.getResults() );
assertEquals( 2, rsp.getResults().getNumFound() );
// System.out.println( rsp.getResults() );
// query outside ascii range
query.setQuery("name:h\u1234llo");
rsp = server.query( query );
assertEquals( 1, rsp.getResults().getNumFound() );
}
/**