public virtual void TestCreationWithBlackList()
 {
     TokenFilterFactory factory = TokenFilterFactory("Type", "types", "stoptypes-1.txt, stoptypes-2.txt", "enablePositionIncrements", "true");
     NumericTokenStream input = new NumericTokenStream();
     input.SetIntValue(123); // LUCENENET TODO: Shouldn't this be a property setter?
     factory.Create(input);
 }
 public virtual void TestCreationWithWhiteList()
 {
     TokenFilterFactory factory = TokenFilterFactory("Type", "types", "stoptypes-1.txt, stoptypes-2.txt", "enablePositionIncrements", "true", "useWhitelist", "true");
     NumericTokenStream input = new NumericTokenStream();
     input.SetIntValue(123);
     factory.Create(input);
 }
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public void testCreationWithBlackList() throws Exception
 public virtual void testCreationWithBlackList()
 {
     TokenFilterFactory factory = tokenFilterFactory("Type", "types", "stoptypes-1.txt, stoptypes-2.txt", "enablePositionIncrements", "true");
     NumericTokenStream input = new NumericTokenStream();
     input.IntValue = 123;
     factory.create(input);
 }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testCreationWithWhiteList() throws Exception
        public virtual void testCreationWithWhiteList()
        {
            TokenFilterFactory factory = tokenFilterFactory("Type", "types", "stoptypes-1.txt, stoptypes-2.txt", "enablePositionIncrements", "true", "useWhitelist", "true");
            NumericTokenStream input   = new NumericTokenStream();

            input.IntValue = 123;
            factory.create(input);
        }
        public virtual void TestCreationWithBlackList()
        {
            TokenFilterFactory factory = TokenFilterFactory("Type", "types", "stoptypes-1.txt, stoptypes-2.txt", "enablePositionIncrements", "true");
            NumericTokenStream input   = new NumericTokenStream();

            input.SetInt32Value(123);
            factory.Create(input);
        }
Ejemplo n.º 6
0
        public virtual void TestCreationWithBlackList()
        {
            TokenFilterFactory factory = TokenFilterFactory("Type", "types", "stoptypes-1.txt, stoptypes-2.txt", "enablePositionIncrements", "true");
            NumericTokenStream input   = new NumericTokenStream();

            input.SetIntValue(123); // LUCENENET TODO: Shouldn't this be a property setter?
            factory.Create(input);
        }
Ejemplo n.º 7
0
        public TokenStream GetTokenStream(Analyzer analyzer)
        {
            if (!((FieldType)FieldType()).Indexed)
            {
                return(null);
            }
            Number n = new Number();

            FieldType.NumericType?numericType = ((FieldType)FieldType()).NumericTypeValue;
            if (numericType != null)
            {
                if (!(InternalTokenStream is NumericTokenStream))
                {
                    // lazy init the TokenStream as it is heavy to instantiate
                    // (attributes,...) if not needed (stored field loading)
                    InternalTokenStream = new NumericTokenStream(Type.NumericPrecisionStep);
                }
                NumericTokenStream nts = (NumericTokenStream)InternalTokenStream;
                // initialize value in TokenStream
                object val = FieldsData;
                switch (numericType)
                {
                case Documents.FieldType.NumericType.INT:
                    nts.SetIntValue(Convert.ToInt32(val));
                    break;

                case Documents.FieldType.NumericType.LONG:
                    nts.SetLongValue(Convert.ToInt64(val));
                    break;

                case Documents.FieldType.NumericType.FLOAT:
                    nts.SetFloatValue(Convert.ToSingle(val));
                    break;

                case Documents.FieldType.NumericType.DOUBLE:
                    nts.SetDoubleValue(Convert.ToDouble(val));
                    break;

                default:
                    throw new Exception("Should never get here");
                }
                return(InternalTokenStream);
            }

            if (!((FieldType)FieldType()).Tokenized)
            {
                if (StringValue == null)
                {
                    throw new System.ArgumentException("Non-Tokenized Fields must have a String value");
                }
                if (!(InternalTokenStream is StringTokenStream))
                {
                    // lazy init the TokenStream as it is heavy to instantiate
                    // (attributes,...) if not needed (stored field loading)
                    InternalTokenStream = new StringTokenStream();
                }
                ((StringTokenStream)InternalTokenStream).Value = StringValue;
                return(InternalTokenStream);
            }

            if (TokenStream_Renamed != null)
            {
                return(TokenStream_Renamed);
            }
            else if (ReaderValue != null)
            {
                return(analyzer.TokenStream(Name(), ReaderValue));
            }
            else if (StringValue != null)
            {
                TextReader sr = new StringReader(StringValue);
                return(analyzer.TokenStream(Name(), sr));
            }

            throw new System.ArgumentException("Field must have either TokenStream, String, Reader or Number value; got " + this);
        }
Ejemplo n.º 8
0
 /// <summary> Creates a field for numeric values with the specified
 /// <c>precisionStep</c>. The instance is not yet initialized with
 /// a numeric value, before indexing a document containing this field,
 /// set a value using the various set<em>???</em>Value() methods.
 /// </summary>
 /// <param name="name">the field name
 /// </param>
 /// <param name="precisionStep">the used <a href="../search/NumericRangeQuery.html#precisionStepDesc">precision step</a>
 /// </param>
 /// <param name="store">if the field should be stored in plain text form
 /// (according to <c>toString(value)</c> of the used data type)
 /// </param>
 /// <param name="index">if the field should be indexed using <see cref="NumericTokenStream" />
 /// </param>
 public NumericField(System.String name, int precisionStep, Field.Store store, bool index) : base(name, store, index?Field.Index.ANALYZED_NO_NORMS:Field.Index.NO, Field.TermVector.NO)
 {
     OmitTermFreqAndPositions = true;
     tokenStream = new NumericTokenStream(precisionStep);
 }