|
|
-
write byte[] directly to TokenStream
Ryan McKinley 2011-03-23, 03:38
I'm messing with putting binary data directly in the index. I have a field class with:
@Override public TokenStream tokenStreamValue() { byte[] value = (byte[])fieldsData;
Token token = new Token( 0, value.length, "geo" ); token.resizeBuffer( value.length ); BytesRef ref = token.getBytesRef(); ref.bytes = value; ref.length = value.length; ref.offset = 0; token.setLength( ref.length ); return new SingleTokenTokenStream( token ); }
but that is just writing an empty token. Is it possible to set the Token value without converting to char[]?
thanks ryan
---------------------------------------------------------------------
-
Re: write byte[] directly to TokenStream
Robert Muir 2011-03-23, 05:04
On Mar 22, 2011 11:38 PM, "Ryan McKinley" <[EMAIL PROTECTED]> wrote: > > I'm messing with putting binary data directly in the index. I have a > field class with: > > @Override > public TokenStream tokenStreamValue() { > byte[] value = (byte[])fieldsData; > > Token token = new Token( 0, value.length, "geo" ); > token.resizeBuffer( value.length ); > BytesRef ref = token.getBytesRef(); > ref.bytes = value; > ref.length = value.length; > ref.offset = 0; > token.setLength( ref.length ); > return new SingleTokenTokenStream( token ); > } > > but that is just writing an empty token. Is it possible to set the > Token value without converting to char[]? >
check out Test2BTerms for an example...
-
Re: write byte[] directly to TokenStream
Ryan McKinley 2011-03-23, 18:34
works great - thanks! On Wed, Mar 23, 2011 at 1:04 AM, Robert Muir <[EMAIL PROTECTED]> wrote: > > On Mar 22, 2011 11:38 PM, "Ryan McKinley" <[EMAIL PROTECTED]> wrote: >> >> I'm messing with putting binary data directly in the index. I have a >> field class with: >> >> @Override >> public TokenStream tokenStreamValue() { >> byte[] value = (byte[])fieldsData; >> >> Token token = new Token( 0, value.length, "geo" ); >> token.resizeBuffer( value.length ); >> BytesRef ref = token.getBytesRef(); >> ref.bytes = value; >> ref.length = value.length; >> ref.offset = 0; >> token.setLength( ref.length ); >> return new SingleTokenTokenStream( token ); >> } >> >> but that is just writing an empty token. Is it possible to set the >> Token value without converting to char[]? >> > > check out Test2BTerms for an example... >
---------------------------------------------------------------------
|
|
All projects made searchable here are trademarks of the Apache Software Foundation.
Service operated by
Sematext