当前位置: 首页>>代码示例>>C#>>正文


C# Lucene.Net.Documents.Document.Fields方法代码示例

本文整理汇总了C#中Lucene.Net.Documents.Document.Fields方法的典型用法代码示例。如果您正苦于以下问题:C# Lucene.Net.Documents.Document.Fields方法的具体用法?C# Lucene.Net.Documents.Document.Fields怎么用?C# Lucene.Net.Documents.Document.Fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Documents.Document的用法示例。


在下文中一共展示了Lucene.Net.Documents.Document.Fields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Add

		/// <summary>Adds field info for a Document. </summary>
		public void  Add(Document doc)
		{
	foreach(Field field in doc.Fields())
	{
				Add(field.Name(), field.IsIndexed(), field.IsTermVectorStored(), field.IsStorePositionWithTermVector(), field.IsStoreOffsetWithTermVector(), field.GetOmitNorms());
			}
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:8,代码来源:FieldInfos.cs

示例2: InvertDocument

        // Tokenizes the fields of a document into Postings.
        private void InvertDocument(Document doc)
        {
            foreach(Field field in doc.Fields())
            {
                System.String fieldName = field.Name();
                int fieldNumber = fieldInfos.FieldNumber(fieldName);

                int length = fieldLengths[fieldNumber]; // length of field
                int position = fieldPositions[fieldNumber]; // position in field
                if (length > 0)
                    position += analyzer.GetPositionIncrementGap(fieldName);
                int offset = fieldOffsets[fieldNumber]; // offset field

                if (field.IsIndexed())
                {
                    if (!field.IsTokenized())
                    {
                        // un-tokenized field
                        System.String stringValue = field.StringValue();
                        if (field.IsStoreOffsetWithTermVector())
                            AddPosition(fieldName, stringValue, position++, new TermVectorOffsetInfo(offset, offset + stringValue.Length));
                        else
                            AddPosition(fieldName, stringValue, position++, null);
                        offset += stringValue.Length;
                        length++;
                    }
                    else
                    {
                        System.IO.TextReader reader; // find or make Reader
                        if (field.ReaderValue() != null)
                            reader = field.ReaderValue();
                        else if (field.StringValue() != null)
                            reader = new System.IO.StringReader(field.StringValue());
                        else
                            throw new System.ArgumentException("field must have either String or Reader value");

                        // Tokenize field and add to postingTable
                        TokenStream stream = analyzer.TokenStream(fieldName, reader);
                        try
                        {
                            Token lastToken = null;
                            for (Token t = stream.Next(); t != null; t = stream.Next())
                            {
                                position += (t.GetPositionIncrement() - 1);

                                if (field.IsStoreOffsetWithTermVector())
                                    AddPosition(fieldName, t.TermText(), position++, new TermVectorOffsetInfo(offset + t.StartOffset(), offset + t.EndOffset()));
                                else
                                    AddPosition(fieldName, t.TermText(), position++, null);

                                lastToken = t;
                                if (++length > maxFieldLength)
                                {
                                    if (infoStream != null)
                                        infoStream.WriteLine("maxFieldLength " + maxFieldLength + " reached, ignoring following tokens");
                                    break;
                                }
                            }

                            if (lastToken != null)
                                offset += lastToken.EndOffset() + 1;
                        }
                        finally
                        {
                            stream.Close();
                        }
                    }

                    fieldLengths[fieldNumber] = length; // save field length
                    fieldPositions[fieldNumber] = position; // save field position
                    fieldBoosts[fieldNumber] *= field.GetBoost();
                    fieldOffsets[fieldNumber] = offset;
                }
            }
        }
开发者ID:kipropesque,项目名称:RuralCafe,代码行数:76,代码来源:DocumentWriter.cs

示例3: NumFields

		public static int NumFields(Document doc)
		{
            int result = 0;
            foreach (Field field in doc.Fields())
            {
                System.Object generatedAux = field;
                result++;
            }
            return result;
		}
开发者ID:emtees,项目名称:old-code,代码行数:10,代码来源:DocHelper.cs

示例4: AddDocument

        internal void AddDocument(Document doc)
        {
            indexStream.WriteLong(fieldsStream.GetFilePointer());

            int storedCount = 0;
            foreach (Field field  in doc.Fields())
            {
                if (field.IsStored())
                    storedCount++;
            }
            fieldsStream.WriteVInt(storedCount);

            foreach (Field field in doc.Fields())
            {
                if (field.IsStored())
                {
                    fieldsStream.WriteVInt(fieldInfos.FieldNumber(field.Name()));

                    byte bits = 0;
                    if (field.IsTokenized())
                        bits |= FieldsWriter.FIELD_IS_TOKENIZED;
                    if (field.IsBinary())
                        bits |= FieldsWriter.FIELD_IS_BINARY;
                    if (field.IsCompressed())
                        bits |= FieldsWriter.FIELD_IS_COMPRESSED;

                    fieldsStream.WriteByte(bits);

                    if (field.IsCompressed())
                    {
                        // compression is enabled for the current field
                        byte[] data = null;
                        // check if it is a binary field
                        if (field.IsBinary())
                        {
                            data = Compress(field.BinaryValue());
                        }
                        else
                        {
                            data = Compress(System.Text.Encoding.GetEncoding("UTF-8").GetBytes(field.StringValue()));
                        }
                        int len = data.Length;
                        fieldsStream.WriteVInt(len);
                        fieldsStream.WriteBytes(data, len);
                    }
                    else
                    {
                        // compression is disabled for the current field
                        if (field.IsBinary())
                        {
                            byte[] data = field.BinaryValue();
                            int len = data.Length;
                            fieldsStream.WriteVInt(len);
                            fieldsStream.WriteBytes(data, len);
                        }
                        else
                        {
                            fieldsStream.WriteString(field.StringValue());
                        }
                    }
                }
            }
        }
开发者ID:vineelkovvuri,项目名称:ExtendableDesktopSearch,代码行数:63,代码来源:FieldsWriter.cs


注:本文中的Lucene.Net.Documents.Document.Fields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。