> Hi Uwe, > > thanks for the talk suggestion(s)*. > > I was using it for faster term lookups of a long 'id'. How would this be done with > 4.0? Before I did it via Term: > > new Term(fieldName, NumericUtils.longToPrefixCoded(longValue));
If you want to query on a single numeric term value, use NumericRangeQuery.newLongRange(field, ..., value, value, true, true), this rewrites to a simple TermQuery. Otherwise you have to create a BytesRef() object: final BytesRef bytes = new BytesRef(); // for reuse! NumericUtils.longToPrefixCoded(longValue, 0, bytes); // 0 is shift value new Term(fieldName, bytes); > How should I generally do "term lookup" in 4.0 as you said in the video that > 'Term' gets removed somewhen :)? What is the most recommended way and > what is the fastest? Or where can I find "most recent" code in lucene tests to be > used as an example? Term lookup can be done by field and BytesRef: get a TermsEnum for the field and seek to the BytesRef. For strings you can create a UTF-8 encoded Bytesref using new BytesRef(CharSequence). If you need docFreq, ask IndexReader with field name and BytesRef. And so on, it's always the same :-) > > NumericUtils is an internal implementation class, you should not use it. > > What do you want to do? There is no need to call any of its methods > > during indexing or searching. Everything else is advanced. I the > > latter case you should RTFM of BytesRef and realted classes (possibly > > watch the flexible indexing talk done by me in Berlin, Barcelona or > > San Francisco). Lucene moved to binary terms in 4.0 and no longer uses > > character based terms, so the code is different. BytesRef is just a wrapper > around a byte[]. > > > > Uwe > > > > ----- > > Uwe Schindler > > H.-H.-Meier-Allee 63, D-28213 Bremen > > http://www.thetaphi.de > > eMail: u...@thetaphi.de > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org