/// <summary>
        /// Returns the field data for a given doc.
        /// </summary>
        /// <param name="docid">doc</param>
        /// <param name="fieldname">name of the field</param>
        /// <returns>field data</returns>
        public virtual string[] GetFieldVal(int docid, string fieldname)
        {
            var facetHandler = GetFacetHandler(fieldname);

            if (facetHandler != null)
            {
                return(facetHandler.GetFieldValues(_reader, docid));
            }
            else
            {
                logger.Warn("facet handler: " + fieldname
                            + " not defined, looking at stored field.");
                // this is not predefined, so it will be slow
                Document doc = _reader.Document(docid, new BoboSubBrowserFieldSelector(fieldname));

                return(doc.GetValues(fieldname));
            }
        }
        public override Document Document(int docid)
        {
            if (_subReaders != null)
            {
                int             readerIndex = ReaderIndex(docid, _starts, _subReaders.Length);
                BoboIndexReader subReader   = _subReaders[readerIndex];
                return(subReader.Document(docid - _starts[readerIndex]));
            }
            else
            {
                Document doc           = base.Document(docid);
                var      facetHandlers = _facetHandlerMap.Values;
                foreach (var facetHandler in facetHandlers)
                {
                    string[] vals = facetHandler.GetFieldValues(this, docid);
                    if (vals != null)
                    {
                        string[] values     = doc.GetValues(facetHandler.Name);
                        var      storedVals = new HashSet <string>(values);

                        foreach (string val in vals)
                        {
                            storedVals.Add(val);
                        }
                        doc.RemoveField(facetHandler.Name);

                        foreach (var val in storedVals)
                        {
                            doc.Add(new Field(facetHandler.Name,
                                              val,
                                              Field.Store.NO,
                                              Field.Index.NOT_ANALYZED));
                        }
                    }
                }
                return(doc);
            }
        }