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 jlist9 <jl...@gmail.com> on 2010/06/07 20:33:15 UTC

solrj Unicode queries don't return results

Hi, I'm having a problem with Unicode queries using solrj.
I have an index with unicode strings. From /solr/admin web interface,
I can find results using the Java unicode format, such as \u751f\u6d3b.
(If I just type in a UTF-8 string, I can't find any result though. Not
sure why.)

But in solrj, I tried having the string in UTF-8 in UTF-8 encoded Java source
file, and I also tried using the Java unicode format in query.setQuery( ),
but none of these approaches return any results.

When I searched online, I found a similar question here w/o no answers.
http://www.mail-archive.com/solr-user@lucene.apache.org/msg21380.html

So what's the right way of doing unicode queries with solrj?

Thank you,
Jack

Re: solrj Unicode queries don't return results

Posted by Lance Norskog <go...@gmail.com>.
Also, you may need this system property in your client app:

java -Dfile.encoding=utf-8 ......

On Tue, Jun 8, 2010 at 4:52 PM, jlist9 <jl...@gmail.com> wrote:
> Ah, I didn't know this. This should be much simpler. Thank you very much!
>
> On Tue, Jun 8, 2010 at 12:57 AM, Ahmet Arslan <io...@yahoo.com> wrote:
>>> Meanwhile, I'd like to try using POST, but I didn't find
>>> information
>>> about how to do this. Could someone point me to a link to
>>> some
>>> sample code?
>>
>>
>> you can pass METHOD.POST to query method of SolrServer.
>>
>> public QueryResponse query(SolrParams params, METHOD method)
>>
>>
>>
>>
>



-- 
Lance Norskog
goksron@gmail.com

Re: solrj Unicode queries don't return results

Posted by jlist9 <jl...@gmail.com>.
Ah, I didn't know this. This should be much simpler. Thank you very much!

On Tue, Jun 8, 2010 at 12:57 AM, Ahmet Arslan <io...@yahoo.com> wrote:
>> Meanwhile, I'd like to try using POST, but I didn't find
>> information
>> about how to do this. Could someone point me to a link to
>> some
>> sample code?
>
>
> you can pass METHOD.POST to query method of SolrServer.
>
> public QueryResponse query(SolrParams params, METHOD method)
>
>
>
>

Re: solrj Unicode queries don't return results

Posted by jlist9 <jl...@gmail.com>.
I was using SolrQuery. Now I'm switching to QueryRequest.
Hope this works. Thanks!

On Mon, Jun 7, 2010 at 11:26 PM, jlist9 <jl...@gmail.com> wrote:
> Thank you for the reply! I'm using Tomcat 6.0.20. I read the page.
> I think you meant setting URIEncoding for the connector:
> <Connector ... URIEncoding="UTF-8"/>
>
> I tried this but it still doesn't work, while the Python client still
> works fine.
> Because the Python client works fine, I tend to think that solrj is not
> encoding the URL properly, as opposed to Tomcat not decoding it correctly.
> Is there anything I should do to make solrj do the right thing?
>
> Meanwhile, I'd like to try using POST, but I didn't find information
> about how to do this. Could someone point me to a link to some
> sample code?
>
> On Mon, Jun 7, 2010 at 11:42 AM, Tim Gilbert
> <TI...@morningstar.com> wrote:
>> I had the same problem a while back. You didn't mention which
>> application server you are using (if any) but some application servers
>> have problems with UTF-8 queries and GET.
>>
>> Tomcat has a well documented solution
>> http://wiki.apache.org/solr/SolrTomcat (near the bottom), I recently
>> experienced problems with glassfish and switched to post to solve it
>> (http://wiki.apache.org/solr/SolrGlassfish)
>>
>> Tim
>>
>> -----Original Message-----
>> From: jlist9 [mailto:jlist9@gmail.com]
>> Sent: Monday, June 07, 2010 2:33 PM
>> To: solr-user@lucene.apache.org
>> Cc: dioxide.software@gmail.com
>> Subject: solrj Unicode queries don't return results
>>
>> Hi, I'm having a problem with Unicode queries using solrj.
>> I have an index with unicode strings. From /solr/admin web interface,
>> I can find results using the Java unicode format, such as \u751f\u6d3b.
>> (If I just type in a UTF-8 string, I can't find any result though. Not
>> sure why.)
>>
>> But in solrj, I tried having the string in UTF-8 in UTF-8 encoded Java
>> source
>> file, and I also tried using the Java unicode format in query.setQuery(
>> ),
>> but none of these approaches return any results.
>>
>> When I searched online, I found a similar question here w/o no answers.
>> http://www.mail-archive.com/solr-user@lucene.apache.org/msg21380.html
>>
>> So what's the right way of doing unicode queries with solrj?
>>
>> Thank you,
>> Jack
>>
>

Re: solrj Unicode queries don't return results

Posted by Ahmet Arslan <io...@yahoo.com>.
> Meanwhile, I'd like to try using POST, but I didn't find
> information
> about how to do this. Could someone point me to a link to
> some
> sample code?

 
you can pass METHOD.POST to query method of SolrServer.

public QueryResponse query(SolrParams params, METHOD method)  


      

Re: solrj Unicode queries don't return results

Posted by jlist9 <jl...@gmail.com>.
Thank you for the reply! I'm using Tomcat 6.0.20. I read the page.
I think you meant setting URIEncoding for the connector:
<Connector ... URIEncoding="UTF-8"/>

I tried this but it still doesn't work, while the Python client still
works fine.
Because the Python client works fine, I tend to think that solrj is not
encoding the URL properly, as opposed to Tomcat not decoding it correctly.
Is there anything I should do to make solrj do the right thing?

Meanwhile, I'd like to try using POST, but I didn't find information
about how to do this. Could someone point me to a link to some
sample code?

On Mon, Jun 7, 2010 at 11:42 AM, Tim Gilbert
<TI...@morningstar.com> wrote:
> I had the same problem a while back. You didn't mention which
> application server you are using (if any) but some application servers
> have problems with UTF-8 queries and GET.
>
> Tomcat has a well documented solution
> http://wiki.apache.org/solr/SolrTomcat (near the bottom), I recently
> experienced problems with glassfish and switched to post to solve it
> (http://wiki.apache.org/solr/SolrGlassfish)
>
> Tim
>
> -----Original Message-----
> From: jlist9 [mailto:jlist9@gmail.com]
> Sent: Monday, June 07, 2010 2:33 PM
> To: solr-user@lucene.apache.org
> Cc: dioxide.software@gmail.com
> Subject: solrj Unicode queries don't return results
>
> Hi, I'm having a problem with Unicode queries using solrj.
> I have an index with unicode strings. From /solr/admin web interface,
> I can find results using the Java unicode format, such as \u751f\u6d3b.
> (If I just type in a UTF-8 string, I can't find any result though. Not
> sure why.)
>
> But in solrj, I tried having the string in UTF-8 in UTF-8 encoded Java
> source
> file, and I also tried using the Java unicode format in query.setQuery(
> ),
> but none of these approaches return any results.
>
> When I searched online, I found a similar question here w/o no answers.
> http://www.mail-archive.com/solr-user@lucene.apache.org/msg21380.html
>
> So what's the right way of doing unicode queries with solrj?
>
> Thank you,
> Jack
>

RE: solrj Unicode queries don't return results

Posted by Tim Gilbert <TI...@morningstar.com>.
I had the same problem a while back. You didn't mention which
application server you are using (if any) but some application servers
have problems with UTF-8 queries and GET.

Tomcat has a well documented solution
http://wiki.apache.org/solr/SolrTomcat (near the bottom), I recently
experienced problems with glassfish and switched to post to solve it
(http://wiki.apache.org/solr/SolrGlassfish)

Tim

-----Original Message-----
From: jlist9 [mailto:jlist9@gmail.com] 
Sent: Monday, June 07, 2010 2:33 PM
To: solr-user@lucene.apache.org
Cc: dioxide.software@gmail.com
Subject: solrj Unicode queries don't return results

Hi, I'm having a problem with Unicode queries using solrj.
I have an index with unicode strings. From /solr/admin web interface,
I can find results using the Java unicode format, such as \u751f\u6d3b.
(If I just type in a UTF-8 string, I can't find any result though. Not
sure why.)

But in solrj, I tried having the string in UTF-8 in UTF-8 encoded Java
source
file, and I also tried using the Java unicode format in query.setQuery(
),
but none of these approaches return any results.

When I searched online, I found a similar question here w/o no answers.
http://www.mail-archive.com/solr-user@lucene.apache.org/msg21380.html

So what's the right way of doing unicode queries with solrj?

Thank you,
Jack