Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peng 41 posts 62 karma points
    Oct 10, 2010 @ 06:18
    Peng
    0

    Examine - call indexall() method but index files are about 1k each

     

    HI guys,
    Currently I am using umbraco 4.5 and examine CR3 to do index and search. I tried to use indexall() and reindex (...) method to re-index content pages. But I noticed the size of index files were very small and they were about 1k each. Fortunately after deleting all the files in the index folder (eg:App_data/examine/internal/*.*) and re-publishing pages in the whole site, the size of index files became 230 K+. 
     Do I need to delete all the index files first then re-index (See the testing code from http://examine.codeplex.com/SourceControl/changeset/view/57718#1078393)? 
    Or is there any setting I missed here (suppose that site will be re-index automatically regularly)? 
     public void Index_Reindex_Content()
            {
                var searcher = (UmbracoExamineSearcher)ExamineManager.Instance.SearchProviderCollection["CWSSearcher"];
    
                Trace.WriteLine("Searcher folder is " + searcher.LuceneIndexFolder.FullName);
                var s = searcher.GetSearcher();
    
                //first delete all 'Content' (not media). This is done by directly manipulating the index with the Lucene API, not examine!
                var r = IndexReader.Open(s.GetIndexReader().Directory(), false);            
                var contentTerm = new Term(UmbracoExamineIndexer.IndexTypeFieldName, IndexTypes.Content);
                var delCount = r.DeleteDocuments(contentTerm);                        
                r.Commit();
                r.Close();
    
                //make sure the content is gone. This is done with lucene APIs, not examine!
                var collector = new AllHitsCollector(false, true);
                var query = new TermQuery(contentTerm);
                s = searcher.GetSearcher(); //make sure the searcher is up do date.
                s.Search(query, collector);
                Assert.AreEqual(0, collector.Count);
    
                        ........
    Thanks in advance!
    Peng 

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 10, 2010 @ 11:54
    Aaron Powell
    0

    Where's this code running, in your custom indexer or just in an application consuming the indexer & searcher?

    Depending on how you're running examine, if you're running it in async mode then you end up with .add and .del files which represent all the index changes which need to be done. These will be processed when the timer runs.
    You shouldn't need to be interacting with Lucene at all.

Please Sign in or register to post replies

Write your reply to:

Draft