Examples of NumericTokenStream


Examples of org.apache.lucene.analysis.NumericTokenStream

        final int precisionStep = 8;
        final double value = randomDouble();
        NumericDoubleAnalyzer analyzer = new NumericDoubleAnalyzer(precisionStep);

        final TokenStream ts1 = analyzer.tokenStream("dummy", String.valueOf(value));
        final NumericTokenStream ts2 = new NumericTokenStream(precisionStep);
        ts2.setDoubleValue(value);
        final NumericTermAttribute numTerm1 = ts1.addAttribute(NumericTermAttribute.class);
        final NumericTermAttribute numTerm2 = ts1.addAttribute(NumericTermAttribute.class);
        final PositionIncrementAttribute posInc1 = ts1.addAttribute(PositionIncrementAttribute.class);
        final PositionIncrementAttribute posInc2 = ts1.addAttribute(PositionIncrementAttribute.class);
        ts1.reset();
        ts2.reset();
        while (ts1.incrementToken()) {
            assertThat(ts2.incrementToken(), is(true));
            assertThat(posInc1, equalTo(posInc2));
            // can't use equalTo directly on the numeric attribute cause it doesn't implement equals (LUCENE-5070)
            assertThat(numTerm1.getRawValue(), equalTo(numTerm2.getRawValue()));
            assertThat(numTerm2.getShift(), equalTo(numTerm2.getShift()));
        }
        assertThat(ts2.incrementToken(), is(false));
        ts1.end();
        ts2.end();
    }
View Full Code Here

Examples of org.apache.lucene.analysis.NumericTokenStream

*
*/
public class NumericFloatTokenizer extends NumericTokenizer {

    public NumericFloatTokenizer(int precisionStep, char[] buffer) throws IOException {
        super(new NumericTokenStream(precisionStep), buffer, null);
    }
View Full Code Here

Examples of org.apache.lucene.analysis.NumericTokenStream

   * @param index if the field should be indexed using {@link NumericTokenStream}
   */
  public NumericField(String name, int precisionStep, Field.Store store, boolean index) {
    super(name, store, index ? Field.Index.ANALYZED_NO_NORMS : Field.Index.NO, Field.TermVector.NO);
    setOmitTermFreqAndPositions(true);
    numericTS = new NumericTokenStream(precisionStep);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.