本文整理汇总了C#中FieldType.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# FieldType.Freeze方法的具体用法?C# FieldType.Freeze怎么用?C# FieldType.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldType
的用法示例。
在下文中一共展示了FieldType.Freeze方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LuceneHighlighter
static LuceneHighlighter()
{
ExtendedTextFieldType = new FieldType(TextField.TYPE_STORED);
ExtendedTextFieldType.SetStoreTermVectors(true);
ExtendedTextFieldType.SetStoreTermVectorOffsets(true);
ExtendedTextFieldType.SetStoreTermVectorPositions(true);
ExtendedTextFieldType.Freeze();
_ramBufferSizeMB = Double.Parse(ConfigurationManager.AppSettings["IndexWriter.RAMBufferSizeMB"] ?? "128");
}
示例2: BeforeClass
public static void BeforeClass()
{
NoDocs = AtLeast(4096);
Distance = (1 << 30) / NoDocs;
Directory = NewDirectory();
RandomIndexWriter writer = new RandomIndexWriter(Random(), Directory, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(TestUtil.NextInt(Random(), 100, 1000)).SetMergePolicy(NewLogMergePolicy()));
FieldType storedInt = new FieldType(IntField.TYPE_NOT_STORED);
storedInt.Stored = true;
storedInt.Freeze();
FieldType storedInt8 = new FieldType(storedInt);
storedInt8.NumericPrecisionStep = 8;
FieldType storedInt4 = new FieldType(storedInt);
storedInt4.NumericPrecisionStep = 4;
FieldType storedInt2 = new FieldType(storedInt);
storedInt2.NumericPrecisionStep = 2;
FieldType storedIntNone = new FieldType(storedInt);
storedIntNone.NumericPrecisionStep = int.MaxValue;
FieldType unstoredInt = IntField.TYPE_NOT_STORED;
FieldType unstoredInt8 = new FieldType(unstoredInt);
unstoredInt8.NumericPrecisionStep = 8;
FieldType unstoredInt4 = new FieldType(unstoredInt);
unstoredInt4.NumericPrecisionStep = 4;
FieldType unstoredInt2 = new FieldType(unstoredInt);
unstoredInt2.NumericPrecisionStep = 2;
IntField field8 = new IntField("field8", 0, storedInt8), field4 = new IntField("field4", 0, storedInt4), field2 = new IntField("field2", 0, storedInt2), fieldNoTrie = new IntField("field" + int.MaxValue, 0, storedIntNone), ascfield8 = new IntField("ascfield8", 0, unstoredInt8), ascfield4 = new IntField("ascfield4", 0, unstoredInt4), ascfield2 = new IntField("ascfield2", 0, unstoredInt2);
Document doc = new Document();
// add fields, that have a distance to test general functionality
doc.Add(field8);
doc.Add(field4);
doc.Add(field2);
doc.Add(fieldNoTrie);
// add ascending fields with a distance of 1, beginning at -noDocs/2 to test the correct splitting of range and inclusive/exclusive
doc.Add(ascfield8);
doc.Add(ascfield4);
doc.Add(ascfield2);
// Add a series of noDocs docs with increasing int values
for (int l = 0; l < NoDocs; l++)
{
int val = Distance * l + StartOffset;
field8.IntValue = val;
field4.IntValue = val;
field2.IntValue = val;
fieldNoTrie.IntValue = val;
val = l - (NoDocs / 2);
ascfield8.IntValue = val;
ascfield4.IntValue = val;
ascfield2.IntValue = val;
writer.AddDocument(doc);
}
Reader = writer.Reader;
Searcher = NewSearcher(Reader);
writer.Dispose();
}
示例3: FieldType
protected internal virtual FieldType FieldType(Options options)
{
FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
ft.StoreTermVectors = true;
ft.StoreTermVectorPositions = (new OptionsWrapper(options)).positions;
ft.StoreTermVectorOffsets = (new OptionsWrapper(options)).offsets;
ft.StoreTermVectorPayloads = (new OptionsWrapper(options)).payloads;
ft.Freeze();
return ft;
}
示例4: TranslateFieldType
public static FieldType TranslateFieldType(Store store, Index index, TermVector termVector)
{
FieldType ft = new FieldType();
ft.Stored = store == Store.YES;
switch (index)
{
case Index.ANALYZED:
ft.Indexed = true;
ft.Tokenized = true;
break;
case Index.ANALYZED_NO_NORMS:
ft.Indexed = true;
ft.Tokenized = true;
ft.OmitNorms = true;
break;
case Index.NOT_ANALYZED:
ft.Indexed = true;
ft.Tokenized = false;
break;
case Index.NOT_ANALYZED_NO_NORMS:
ft.Indexed = true;
ft.Tokenized = false;
ft.OmitNorms = true;
break;
case Index.NO:
break;
}
switch (termVector)
{
case TermVector.NO:
break;
case TermVector.YES:
ft.StoreTermVectors = true;
break;
case TermVector.WITH_POSITIONS:
ft.StoreTermVectors = true;
ft.StoreTermVectorPositions = true;
break;
case TermVector.WITH_OFFSETS:
ft.StoreTermVectors = true;
ft.StoreTermVectorOffsets = true;
break;
case TermVector.WITH_POSITIONS_OFFSETS:
ft.StoreTermVectors = true;
ft.StoreTermVectorPositions = true;
ft.StoreTermVectorOffsets = true;
break;
}
ft.Freeze();
return ft;
}
示例5: Test
public virtual void Test()
{
MockDirectoryWrapper dir = new MockDirectoryWrapper(Random(), new MMapDirectory(CreateTempDir("4GBStoredFields")));
dir.Throttling = MockDirectoryWrapper.Throttling_e.NEVER;
IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH).SetRAMBufferSizeMB(256.0).SetMergeScheduler(new ConcurrentMergeScheduler()).SetMergePolicy(NewLogMergePolicy(false, 10)).SetOpenMode(IndexWriterConfig.OpenMode_e.CREATE));
MergePolicy mp = w.Config.MergePolicy;
if (mp is LogByteSizeMergePolicy)
{
// 1 petabyte:
((LogByteSizeMergePolicy)mp).MaxMergeMB = 1024 * 1024 * 1024;
}
Document doc = new Document();
FieldType ft = new FieldType();
ft.Indexed = false;
ft.Stored = true;
ft.Freeze();
int valueLength = RandomInts.NextIntBetween(Random(), 1 << 13, 1 << 20);
sbyte[] value = new sbyte[valueLength];
for (int i = 0; i < valueLength; ++i)
{
// random so that even compressing codecs can't compress it
value[i] = (sbyte)Random().Next(256);
}
Field f = new Field("fld", value, ft);
doc.Add(f);
int numDocs = (int)((1L << 32) / valueLength + 100);
for (int i = 0; i < numDocs; ++i)
{
w.AddDocument(doc);
if (VERBOSE && i % (numDocs / 10) == 0)
{
Console.WriteLine(i + " of " + numDocs + "...");
}
}
w.ForceMerge(1);
w.Dispose();
if (VERBOSE)
{
bool found = false;
foreach (string file in dir.ListAll())
{
if (file.EndsWith(".fdt"))
{
long fileLength = dir.FileLength(file);
if (fileLength >= 1L << 32)
{
found = true;
}
Console.WriteLine("File length of " + file + " : " + fileLength);
}
}
if (!found)
{
Console.WriteLine("No .fdt file larger than 4GB, test bug?");
}
}
DirectoryReader rd = DirectoryReader.Open(dir);
Document sd = rd.Document(numDocs - 1);
Assert.IsNotNull(sd);
Assert.AreEqual(1, sd.Fields.Count);
BytesRef valueRef = sd.GetBinaryValue("fld");
Assert.IsNotNull(valueRef);
Assert.AreEqual(new BytesRef(value), valueRef);
rd.Dispose();
dir.Dispose();
}