示例#1
0
        // Returns a list of all files and directories in dir
        static ICollection GetAllItemsInDirectory(DirectoryInfo dir)
        {
            // form the query
            string parent_uri_str = PathToUri(dir.FullName).ToString();

            // Instead of taking the painfull way of using BeagrepAnalyzer, lets just add the prefix manually
            // LuceneCommon thinks exposing secret property type encoding is bad, I think so too... except for now
            string key = "prop:k:" + Property.ParentDirUriPropKey;

            //Logger.Log.Debug ("Querying for {0}={1}", parent_uri_str, key);
            LNS.Query query = new LNS.TermQuery(new Term(key, parent_uri_str));

            // do the search
            LNS.IndexSearcher searcher;
            searcher = LuceneCommon.GetSearcher(driver.PrimaryStore);

            BetterBitArray matches;

            matches = new BetterBitArray(searcher.MaxDoc());

            BitArrayHitCollector collector;

            collector = new BitArrayHitCollector(matches);

            searcher.Search(query, null, collector);

            // Finally we pull all of the matching documents,
            // convert them to Dirent, and store them in a list.

            ArrayList match_list = new ArrayList();
            int       i          = 0;

            while (i < matches.Count)
            {
                i = matches.GetNextTrueIndex(i);
                if (i >= matches.Count)
                {
                    break;
                }

                Document doc;
                doc = searcher.Doc(i);

                Dirent info;
                info = DocumentToDirent(doc);

                match_list.Add(info);

                ++i;
            }

            LuceneCommon.ReleaseSearcher(searcher);
            //Logger.Log.Debug ("Found {0} items in {1}", match_list.Count, dir.FullName);

            return(match_list);
        }
示例#2
0
                // Returns a list of all files and directories in dir
                static ICollection GetAllItemsInDirectory (DirectoryInfo dir)
                {
                        // form the query
                        string parent_uri_str = PathToUri (dir.FullName).ToString ();

                        // Instead of taking the painfull way of using BeagrepAnalyzer, lets just add the prefix manually
                        // LuceneCommon thinks exposing secret property type encoding is bad, I think so too... except for now
                        string key = "prop:k:" + Property.ParentDirUriPropKey;
                        //Logger.Log.Debug ("Querying for {0}={1}", parent_uri_str, key);
                        LNS.Query query = new LNS.TermQuery (new Term (key, parent_uri_str));

                        // do the search
                        LNS.IndexSearcher searcher;
                        searcher = LuceneCommon.GetSearcher (driver.PrimaryStore);

                        BetterBitArray matches;
                        matches = new BetterBitArray (searcher.MaxDoc ());

                        BitArrayHitCollector collector;
                        collector = new BitArrayHitCollector (matches);

                        searcher.Search (query, null, collector);

                        // Finally we pull all of the matching documents,
                        // convert them to Dirent, and store them in a list.

                        ArrayList match_list = new ArrayList ();
                        int i = 0;
                        while (i < matches.Count) {

                                i = matches.GetNextTrueIndex (i);
                                if (i >= matches.Count)
                                        break;

                                Document doc;
                                doc = searcher.Doc (i);

                                Dirent info;
                                info = DocumentToDirent (doc);

                                match_list.Add (info);

                                ++i;
                        }

                        LuceneCommon.ReleaseSearcher (searcher);
                        //Logger.Log.Debug ("Found {0} items in {1}", match_list.Count, dir.FullName);

                        return match_list;
                }
示例#3
0
 public LuceneBitArray(LNS.IndexSearcher searcher) : base(searcher.MaxDoc())
 {
     this.searcher  = searcher;
     this.collector = new BitArrayHitCollector();
     this.scratch   = null;
 }
示例#4
0
        // Return all directories with name
        public ICollection GetAllDirectoryNameInfo(string name)
        {
            // First we assemble a query to find all of the directories.
            string field_name;

            field_name = PropertyToFieldName(PropertyType.Keyword,
                                             Property.IsDirectoryPropKey);
            LNS.Query isdir_query = new LNS.TermQuery(new Term(field_name, "true"));

            LNS.Query query = null;

            if (name == null)
            {
                query = isdir_query;
            }
            else
            {
                string dirname_field;
                dirname_field = PropertyToFieldName(PropertyType.Text,
                                                    Property.TextFilenamePropKey);
                LNS.Query dirname_query;
                dirname_query = LuceneCommon.StringToQuery(dirname_field, name, null);
                LNS.BooleanQuery bool_query = new LNS.BooleanQuery();
                bool_query.Add(isdir_query, LNS.BooleanClause.Occur.MUST);
                bool_query.Add(dirname_query, LNS.BooleanClause.Occur.MUST);

                query = bool_query;
            }

            // Then we actually run the query
            LNS.IndexSearcher searcher;
            //searcher = new LNS.IndexSearcher (SecondaryStore);
            searcher = LuceneCommon.GetSearcher(SecondaryStore);

            BetterBitArray matches;

            matches = new BetterBitArray(searcher.MaxDoc());

            BitArrayHitCollector collector;

            collector = new BitArrayHitCollector(matches);

            searcher.Search(query, null, collector);

            // Finally we pull all of the matching documents,
            // convert them to NameInfo, and store them in a list.

            ArrayList match_list = new ArrayList();
            int       i          = 0;

            while (i < matches.Count)
            {
                i = matches.GetNextTrueIndex(i);
                if (i >= matches.Count)
                {
                    break;
                }

                Document doc;
                doc = searcher.Doc(i, fields_nameinfo);

                NameInfo info;
                info = DocumentToNameInfo(doc);

                match_list.Add(info);

                ++i;
            }

            LuceneCommon.ReleaseSearcher(searcher);

            return(match_list);
        }
示例#5
0
		public LuceneBitArray (LNS.IndexSearcher searcher) : base (searcher.MaxDoc ())
		{
			this.searcher = searcher;
			this.collector = new BitArrayHitCollector ();
			this.scratch = null;
		}
示例#6
0
		// Return all directories with name
		public ICollection GetAllDirectoryNameInfo (string name)
		{
			// First we assemble a query to find all of the directories.
			string field_name;
			field_name = PropertyToFieldName (PropertyType.Keyword,
							  Property.IsDirectoryPropKey);
			LNS.Query isdir_query = new LNS.TermQuery (new Term (field_name, "true"));

			LNS.Query query = null;

			if (name == null) {
				query = isdir_query;
			} else {
				string dirname_field;
				dirname_field = PropertyToFieldName (PropertyType.Text,
								     Property.TextFilenamePropKey);
				LNS.Query dirname_query;
				dirname_query = LuceneCommon.StringToQuery (dirname_field, name, null);
				LNS.BooleanQuery bool_query = new LNS.BooleanQuery ();
				bool_query.Add (isdir_query, LNS.BooleanClause.Occur.MUST);
				bool_query.Add (dirname_query, LNS.BooleanClause.Occur.MUST);

				query = bool_query;
			}

			// Then we actually run the query
			LNS.IndexSearcher searcher;
			//searcher = new LNS.IndexSearcher (SecondaryStore);
			searcher = LuceneCommon.GetSearcher (SecondaryStore);

			BetterBitArray matches;
			matches = new BetterBitArray (searcher.MaxDoc ());

			BitArrayHitCollector collector;
			collector = new BitArrayHitCollector (matches);

			searcher.Search (query, null, collector);
			
			// Finally we pull all of the matching documents,
			// convert them to NameInfo, and store them in a list.

			ArrayList match_list = new ArrayList ();
			int i = 0;
			while (i < matches.Count) {
				
				i = matches.GetNextTrueIndex (i);
				if (i >= matches.Count)
					break;

				Document doc;
				doc = searcher.Doc (i, fields_nameinfo);

				NameInfo info;
				info = DocumentToNameInfo (doc);

				match_list.Add (info);

				++i;
			}

			LuceneCommon.ReleaseSearcher (searcher);

			return match_list;
		}