Lucene.Net.Index.AtomicReader.HasNorms C# (CSharp) Method

HasNorms() public method

Returns true if there are norms stored for this field.
public HasNorms ( string field ) : bool
field string
return bool
        public bool HasNorms(string field)
        {
            EnsureOpen();
            // note: using normValues(field) != null would potentially cause i/o
            FieldInfo fi = FieldInfos.FieldInfo(field);
            return fi != null && fi.HasNorms();
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Test field norms.
        /// @lucene.experimental
        /// </summary>
        public static Status.FieldNormStatus TestFieldNorms(AtomicReader reader, TextWriter infoStream)
        {
            Status.FieldNormStatus status = new Status.FieldNormStatus();

            try
            {
                // Test Field Norms
                if (infoStream != null)
                {
                    infoStream.Write("    test: field norms.........");
                }
                foreach (FieldInfo info in reader.FieldInfos)
                {
                    if (info.HasNorms())
                    {
                        Debug.Assert(reader.HasNorms(info.Name)); // deprecated path
                        CheckNorms(info, reader, infoStream);
                        ++status.TotFields;
                    }
                    else
                    {
                        Debug.Assert(!reader.HasNorms(info.Name)); // deprecated path
                        if (reader.GetNormValues(info.Name) != null)
                        {
                            throw new Exception("field: " + info.Name + " should omit norms but has them!");
                        }
                    }
                }

                Msg(infoStream, "OK [" + status.TotFields + " fields]");
            }
            catch (Exception e)
            {
                Msg(infoStream, "ERROR [" + Convert.ToString(e.Message) + "]");
                status.Error = e;
                if (infoStream != null)
                {
                    // LUCENENET NOTE: Some tests rely on the error type being in
                    // the message. We can't get the error type with StackTrace, we
                    // need ToString() for that.
                    infoStream.WriteLine(e.ToString());
                    //infoStream.WriteLine(e.StackTrace);
                }
            }

            return status;
        }