Ejemplo n.º 1
0
 public void AddTextFieldWorks()
 {
     using (var builder = new SchemaBuilder())
         using (var options = new TextOptions())
         {
             uint field1 = builder.AddTextField("test1", options);
             uint field2 = builder.AddTextField("test2", options);
             Assert.NotEqual(field1, field2);
         }
 }
Ejemplo n.º 2
0
        public void BuildWorks()
        {
            using (var builder = new SchemaBuilder())
                using (var options = new TextOptions())
                {
                    uint field1 = builder.AddFacetField(nameof(field1));
                    uint field2 = builder.AddTextField("test2", options);
                    Assert.NotEqual(field1, field2);

                    var schema = builder.Build();
                    Assert.NotNull(schema);
                    Assert.Equal(nameof(field1), schema.GetFieldName(field1));

                    Assert.Throws <ObjectDisposedException>(() => builder.AddFacetField("test3"));
                }
        }
        public IndexWriterTests()
        {
            using (var builder = new SchemaBuilder())
            {
                using (var primaryKeyOptions = new IntOptions().Stored().Fast(Cardinality.SingleValue).Indexed())
                {
                    Id = builder.AddI64Field(nameof(Id), primaryKeyOptions);
                }

                using (var textFieldOptions = new TextFieldIndexing {
                    Tokenizer = DefaultTokenizers.EnglishStemming
                })
                    using (var textOptions = new TextOptions {
                        IndexingOptions = textFieldOptions
                    })
                    {
                        Text = builder.AddTextField(nameof(Text), textOptions);
                    }

                Index = Index.CreateInRam(builder.Build());
            }
        }