public virtual IIndexedNode SelectBestIndex()
        {
            IEnumerator  i    = CollectIndexedNodes();
            IIndexedNode best = null;

            while (i.MoveNext())
            {
                IIndexedNode indexedNode = (IIndexedNode)i.Current;
                IIndexedNode resolved    = ResolveFully(indexedNode);
                if (resolved == null)
                {
                    continue;
                }
                if (best == null)
                {
                    best = indexedNode;
                    continue;
                }
                if (indexedNode.ResultSize() < best.ResultSize())
                {
                    best = indexedNode;
                }
            }
            return(best);
        }
        public virtual IIndexedNode SelectBestIndex()
        {
            IEnumerator i = CollectIndexedNodes();

            if (!i.MoveNext())
            {
                return(null);
            }
            IIndexedNode best = (IIndexedNode)i.Current;

            while (i.MoveNext())
            {
                IIndexedNode leaf = (IIndexedNode)i.Current;
                if (leaf.ResultSize() < best.ResultSize())
                {
                    best = leaf;
                }
            }
            return(best);
        }
        public virtual FieldIndexProcessorResult Run()
        {
            IIndexedNode bestIndex = SelectBestIndex();

            if (null == bestIndex)
            {
                return(FieldIndexProcessorResult.NoIndexFound);
            }
            if (bestIndex.ResultSize() > 0)
            {
                IIndexedNode resolved = ResolveFully(bestIndex);
                if (null == resolved)
                {
                    return(FieldIndexProcessorResult.NoIndexFound);
                }
                resolved.MarkAsBestIndex();
                return(new FieldIndexProcessorResult(resolved));
            }
            return(FieldIndexProcessorResult.FoundIndexButNoMatch);
        }