private NameInfo DocumentToNameInfo(Document doc)
        {
            NameInfo info;

            info = new NameInfo();

            string str;

            str     = doc.Get("Uri");
            info.Id = GuidFu.FromUriString(str);

            bool have_name      = false;
            bool have_parent_id = false;
            bool have_is_dir    = false;

            foreach (Field f in doc.Fields())
            {
                Property prop;
                prop = GetPropertyFromDocument(f, doc, false);
                if (prop == null)
                {
                    continue;
                }

                switch (prop.Key)
                {
                case Property.ExactFilenamePropKey:
                    info.Name = prop.Value;
                    have_name = true;
                    break;

                case Property.ParentDirUriPropKey:
                    info.ParentId  = GuidFu.FromUriString(prop.Value);
                    have_parent_id = true;
                    break;

                case Property.IsDirectoryPropKey:
                    info.IsDirectory = (prop.Value == "true");
                    have_is_dir      = true;
                    break;
                }

                if (have_name && have_parent_id && have_is_dir)
                {
                    break;
                }
            }

            return(info);
        }
        ////////////////////////////////////////////////////////////////

        public Guid GetIdByNameAndParentId(string name, Guid parent_id)
        {
            string parent_uri_str;

            parent_uri_str = GuidFu.ToUriString(parent_id);

            string key1, key2;

            key1 = PropertyToFieldName(PropertyType.Keyword, Property.ParentDirUriPropKey);
            key2 = PropertyToFieldName(PropertyType.Keyword, Property.ExactFilenamePropKey);

            Term term1, term2;

            term1 = new Term(key1, parent_uri_str);
            term2 = new Term(key2, name.ToLower());

            // Lets walk the exact file name terms first (term2)
            // since there are probably fewer than parent directory
            // Uri terms.
            List <int> term2_doc_ids = new List <int> ();

            IndexReader reader    = LuceneCommon.GetReader(SecondaryStore);
            TermDocs    term_docs = reader.TermDocs();

            term_docs.Seek(term2);
            while (term_docs.Next())
            {
                term2_doc_ids.Add(term_docs.Doc());
            }

            term_docs.Seek(term1);

            int match_id = -1;

            while (term_docs.Next())
            {
                int doc_id = term_docs.Doc();

                if (term2_doc_ids.BinarySearch(doc_id) >= 0)
                {
                    match_id = doc_id;
                    break;
                }
            }

            term_docs.Close();

            Guid id;

            if (match_id != -1)
            {
                Document doc;
                doc = reader.Document(match_id);
                id  = GuidFu.FromUriString(doc.Get("Uri"));
            }
            else
            {
                id = Guid.Empty;
            }

            LuceneCommon.ReleaseReader(reader);

            return(id);
        }