You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Ruslan Muzhikov <rm...@gmail.com> on 2015/09/08 16:35:09 UTC

Problems with toString at TermsQuery

Hi!
Sometimes TermsQuery.toString() method falls with exception:

*Exception in thread "main" java.lang.AssertionError*
* at org.apache.lucene.util.UnicodeUtil.UTF8toUTF16(UnicodeUtil.java:546)*
* at org.apache.lucene.util.BytesRef.utf8ToString(BytesRef.java:149)*
* at org.apache.lucene.queries.TermsQuery.toString(TermsQuery.java:190)*
* at org.apache.lucene.search.Query.toString(Query.java:67)*
* ...*


Here is the example of such program:

*public static void main(String[] args) {*
*    System.out.print(new TermsQuery(new Term("DATA", new
BytesRef(toBytes(128)))).toString());*
*}*

*public static byte[] toBytes(int val) {*
*    byte[] b = new byte[4];*
*    for(int i = 3; i > 0; i--) {*
*        b[i] = (byte) val;*
*        val >>>= 8;*
*    }*
*    b[0] = (byte) val;*
*    return b;*
*}*


Is there any limits on BytesRef content?

Thanks,
Ruslan Muzhikov

Re: Problems with toString at TermsQuery

Posted by Robert Muir <rc...@gmail.com>.
I think its a bug: https://issues.apache.org/jira/browse/LUCENE-6792

On Tue, Sep 8, 2015 at 10:35 AM, Ruslan Muzhikov <rm...@gmail.com> wrote:
> Hi!
> Sometimes TermsQuery.toString() method falls with exception:
>
> *Exception in thread "main" java.lang.AssertionError*
> * at org.apache.lucene.util.UnicodeUtil.UTF8toUTF16(UnicodeUtil.java:546)*
> * at org.apache.lucene.util.BytesRef.utf8ToString(BytesRef.java:149)*
> * at org.apache.lucene.queries.TermsQuery.toString(TermsQuery.java:190)*
> * at org.apache.lucene.search.Query.toString(Query.java:67)*
> * ...*
>
>
> Here is the example of such program:
>
> *public static void main(String[] args) {*
> *    System.out.print(new TermsQuery(new Term("DATA", new
> BytesRef(toBytes(128)))).toString());*
> *}*
>
> *public static byte[] toBytes(int val) {*
> *    byte[] b = new byte[4];*
> *    for(int i = 3; i > 0; i--) {*
> *        b[i] = (byte) val;*
> *        val >>>= 8;*
> *    }*
> *    b[0] = (byte) val;*
> *    return b;*
> *}*
>
>
> Is there any limits on BytesRef content?
>
> Thanks,
> Ruslan Muzhikov

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org