本文整理汇总了C#中Lucene.Net.Documents.Field.SetOmitNorms方法的典型用法代码示例。如果您正苦于以下问题:C# Field.SetOmitNorms方法的具体用法?C# Field.SetOmitNorms怎么用?C# Field.SetOmitNorms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Documents.Field
的用法示例。
在下文中一共展示了Field.SetOmitNorms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPropertyToDocument
static protected void AddPropertyToDocument (Property prop, Document doc)
{
if (prop == null || String.IsNullOrEmpty (prop.Value))
return;
// Don't actually put properties in the UnindexedNamespace
// in the document. A horrible (and yet lovely!) hack.
if (prop.Key.StartsWith (StringFu.UnindexedNamespace))
return;
Field f;
if (prop.IsSearched) {
string wildcard_field = TypeToWildcardField (prop.Type);
f = new Field (wildcard_field,
prop.Value,
Field.Store.NO,
TypeToIndexInstruction (prop.Type));
// We don't want to include norms for non-text
// fields, even if we do tokenize them.
if (prop.Type == PropertyType.Keyword || prop.Type == PropertyType.Date)
f.SetOmitNorms (true);
doc.Add (f);
if (prop.Type == PropertyType.Date)
AddDateFields (wildcard_field, prop, doc);
}
string coded_value;
coded_value = String.Format ("{0}{1}:{2}",
prop.IsSearched ? 's' : '_',
prop.IsPersistent ? 'p' : '_',
prop.Value);
string field_name = PropertyToFieldName (prop.Type, prop.Key);
f = new Field (field_name,
coded_value,
prop.IsStored ? Field.Store.YES : Field.Store.NO,
Field.Index.TOKENIZED);
doc.Add (f);
if (prop.Type == PropertyType.Date)
AddDateFields (field_name, prop, doc);
}
示例2: AddField
private void AddField(Document doc, FieldInfo fi, bool binary, bool compressed, bool tokenize)
{
//we have a binary stored field, and it may be compressed
if (binary)
{
int toRead = fieldsStream.ReadVInt();
byte[] b = new byte[toRead];
fieldsStream.ReadBytes(b, 0, b.Length);
if (compressed)
doc.Add(new Field(fi.name, Uncompress(b), Field.Store.COMPRESS));
else
doc.Add(new Field(fi.name, b, Field.Store.YES));
}
else
{
Field.Store store = Field.Store.YES;
Field.Index index = GetIndexType(fi, tokenize);
Field.TermVector termVector = GetTermVectorType(fi);
AbstractField f;
if (compressed)
{
store = Field.Store.COMPRESS;
int toRead = fieldsStream.ReadVInt();
byte[] b = new byte[toRead];
fieldsStream.ReadBytes(b, 0, b.Length);
f = new Field(fi.name, false, System.Text.Encoding.GetEncoding("UTF-8").GetString(Uncompress(b)), store, index, termVector);
f.SetOmitTermFreqAndPositions(fi.omitTermFreqAndPositions);
f.SetOmitNorms(fi.omitNorms);
}
else
{
f = new Field(fi.name, false, fieldsStream.ReadString(), store, index, termVector);
f.SetOmitTermFreqAndPositions(fi.omitTermFreqAndPositions);
f.SetOmitNorms(fi.omitNorms);
}
doc.Add(f);
}
}