Examples of NumericTokenStream


Examples of org.apache.lucene.analysis.NumericTokenStream

    Map<String, String> args = new HashMap<String, String>();
    args.put("types", "stoptypes-1.txt, stoptypes-2.txt");
    args.put("enablePositionIncrements", "false");
    typeTokenFilterFactory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
    typeTokenFilterFactory.init(args);
    NumericTokenStream input = new NumericTokenStream();
    input.setIntValue(123);
    typeTokenFilterFactory.create(input);
  }
View Full Code Here

Examples of org.apache.lucene.analysis.NumericTokenStream

      args.put("types", "stoptypes-1.txt, stoptypes-2.txt");
      args.put("enablePositionIncrements", "false");
      args.put("useWhitelist","true");
      typeTokenFilterFactory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
      typeTokenFilterFactory.init(args);
      NumericTokenStream input = new NumericTokenStream();
      input.setIntValue(123);
      typeTokenFilterFactory.create(input);
    }
View Full Code Here

Examples of org.apache.lucene.analysis.NumericTokenStream

    final NumericType numericType = fieldType().numericType();
    if (numericType != null) {
      if (!(reuse instanceof NumericTokenStream && ((NumericTokenStream)reuse).getPrecisionStep() == type.numericPrecisionStep())) {
        // lazy init the TokenStream as it is heavy to instantiate
        // (attributes,...) if not needed (stored field loading)
        reuse = new NumericTokenStream(type.numericPrecisionStep());
      }
      final NumericTokenStream nts = (NumericTokenStream) reuse;
      // initialize value in TokenStream
      final Number val = (Number) fieldsData;
      switch (numericType) {
      case INT:
        nts.setIntValue(val.intValue());
        break;
      case LONG:
        nts.setLongValue(val.longValue());
        break;
      case FLOAT:
        nts.setFloatValue(val.floatValue());
        break;
      case DOUBLE:
        nts.setDoubleValue(val.doubleValue());
        break;
      default:
        throw new AssertionError("Should never get here");
      }
      return reuse;
View Full Code Here

Examples of org.apache.lucene.analysis.NumericTokenStream

        new int[]    { 3 }
    );
   
    // pass a bogus stream and ensure its still ok
    stringField = new StringField("foo", "beer", Field.Store.NO);
    TokenStream bogus = new NumericTokenStream();
    ts = stringField.tokenStream(null, bogus);
    assertNotSame(ts, bogus);
    assertTokenStreamContents(ts,
        new String[] { "beer" },
        new int[]    { 0 },
View Full Code Here

Examples of org.apache.lucene.analysis.NumericTokenStream

    assertNumericContents(2343, ts);
   
    // pass another bogus stream (numeric, but different precision step!)
    intField = new IntField("foo", 42, Field.Store.NO);
    assert 3 != NumericUtils.PRECISION_STEP_DEFAULT;
    bogus = new NumericTokenStream(3);
    ts = intField.tokenStream(null, bogus);
    assertNotSame(bogus, ts);
    assertNumericContents(42, ts);
  }
View Full Code Here

Examples of org.apache.lucene.analysis.NumericTokenStream

    final NumericType numericType = fieldType().numericType();
    if (numericType != null) {
      if (!(internalTokenStream instanceof NumericTokenStream)) {
        // lazy init the TokenStream as it is heavy to instantiate
        // (attributes,...) if not needed (stored field loading)
        internalTokenStream = new NumericTokenStream(type.numericPrecisionStep());
      }
      final NumericTokenStream nts = (NumericTokenStream) internalTokenStream;
      // initialize value in TokenStream
      final Number val = (Number) fieldsData;
      switch (numericType) {
      case INT:
        nts.setIntValue(val.intValue());
        break;
      case LONG:
        nts.setLongValue(val.longValue());
        break;
      case FLOAT:
        nts.setFloatValue(val.floatValue());
        break;
      case DOUBLE:
        nts.setDoubleValue(val.doubleValue());
        break;
      default:
        throw new AssertionError("Should never get here");
      }
      return internalTokenStream;
View Full Code Here

Examples of org.apache.lucene.analysis.NumericTokenStream

  public void testCreationWithBlackList() throws Exception {
    TokenFilterFactory factory = tokenFilterFactory("Type",
        "types", "stoptypes-1.txt, stoptypes-2.txt",
        "enablePositionIncrements", "false");
    NumericTokenStream input = new NumericTokenStream();
    input.setIntValue(123);
    factory.create(input);
  }
View Full Code Here

Examples of org.apache.lucene.analysis.NumericTokenStream

  public void testCreationWithWhiteList() throws Exception {
    TokenFilterFactory factory = tokenFilterFactory("Type",
        "types", "stoptypes-1.txt, stoptypes-2.txt",
        "enablePositionIncrements", "false",
        "useWhitelist", "true");
    NumericTokenStream input = new NumericTokenStream();
    input.setIntValue(123);
    factory.create(input);
  }
View Full Code Here

Examples of org.apache.lucene.analysis.NumericTokenStream

    final NumericType numericType = fieldType().numericType();
    if (numericType != null) {
      if (!(internalTokenStream instanceof NumericTokenStream)) {
        // lazy init the TokenStream as it is heavy to instantiate
        // (attributes,...) if not needed (stored field loading)
        internalTokenStream = new NumericTokenStream(type.numericPrecisionStep());
      }
      final NumericTokenStream nts = (NumericTokenStream) internalTokenStream;
      // initialize value in TokenStream
      final Number val = (Number) fieldsData;
      switch (numericType) {
      case INT:
        nts.setIntValue(val.intValue());
        break;
      case LONG:
        nts.setLongValue(val.longValue());
        break;
      case FLOAT:
        nts.setFloatValue(val.floatValue());
        break;
      case DOUBLE:
        nts.setDoubleValue(val.doubleValue());
        break;
      default:
        throw new AssertionError("Should never get here");
      }
      return internalTokenStream;
View Full Code Here

Examples of org.apache.lucene.analysis.NumericTokenStream

    final NumericType numericType = fieldType().numericType();
    if (numericType != null) {
      if (!(internalTokenStream instanceof NumericTokenStream)) {
        // lazy init the TokenStream as it is heavy to instantiate
        // (attributes,...) if not needed (stored field loading)
        internalTokenStream = new NumericTokenStream(type.numericPrecisionStep());
      }
      final NumericTokenStream nts = (NumericTokenStream) internalTokenStream;
      // initialize value in TokenStream
      final Number val = (Number) fieldsData;
      switch (numericType) {
      case INT:
        nts.setIntValue(val.intValue());
        break;
      case LONG:
        nts.setLongValue(val.longValue());
        break;
      case FLOAT:
        nts.setFloatValue(val.floatValue());
        break;
      case DOUBLE:
        nts.setDoubleValue(val.doubleValue());
        break;
      default:
        throw new AssertionError("Should never get here");
      }
      return internalTokenStream;
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.