Processing the Index Queue follow the demo, no error,but no data when searching the word.

Mar 4, 2013 at 7:32 AM
Edited Mar 5, 2013 at 12:16 AM
CIndex.CreateIndex();
            var indexPath = @"c:\productindex";// Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Index");
            ////var indexSearcher = new DirectoryIndexSearcher(new DirectoryInfo(indexPath), true);
            ////using (var searchService = new SearchService(indexSearcher))
            ////{
            ////    var result = searchService.SearchIndex(new TermQuery(new Term("Name", "football")));
            ////    var luceneDocs = result.Results;
            ////    Console.Write(luceneDocs.First().GetValue("name"));
            ////    Console.ReadLine();
            ////}

            var indexSearcher = new DirectoryIndexSearcher(new DirectoryInfo(indexPath), true);
            //using (var searchService = new SearchService(indexSearcher))
            //{
            //    var query = new ProductQuery().WithKeywords("喜欢");// WithPriceBetween(0, 100);
            //    var result = searchService.SearchIndex(query.Query);
            //    foreach (var doc in result.Results)
            //        Console.WriteLine(doc.GetValue("name"));


            //    Console.ReadLine();
            //}

            var product =  new Product { Id = 6, Name = "Windows Phone",Description="我喜欢", Price = 134.45M, CreatedOn = new DateTime(2010, 9, 18)};
            var product1 = new Product { Id = 7, Name = "Windows Phone7", Description = "我喜欢fgh", Price = 134.45M, CreatedOn = new DateTime(2010, 9, 18) };
            // index location
            var indexLocation = new FileSystemIndexLocation(new DirectoryInfo(indexPath));//@"c:\productindex"
            
            // index definition
            var definition = new ProductIndexDefinition();

            // create the task
            var tt = new EntityUpdateTask<Product>(product, definition, indexLocation);
            var tt1 = new EntityUpdateTask<Product>(product1, definition, indexLocation);

            //var t1 = new EntityUpdateTask<Product>(new Product(), new ProductIndexDefinition(), new TestIndexLocation("products"));
            //var t2 = new EntityUpdateTask<Product>(new Product(), new ProductIndexDefinition(), new TestIndexLocation("products"));
            //var t3 = new EntityUpdateTask<Product>(new Product(), new ProductIndexDefinition(), new TestIndexLocation("products2"));

            Action<IIndexTask> queue = t => IndexQueue.Instance.Queue(t);
            queue(tt);
            queue(tt1);
            //queue(t1);
            //queue(t2);
            //queue(t3);

            var services = new HashSet<IIndexService>();

            IIndexTask task;
            while (IndexQueue.Instance.TryDequeue(out task))
            {
                var service = services.WithOptions(task.IndexOptions);

                if (service == null)
                {
                    service = new IndexService(new DirectoryIndexWriter(task.IndexOptions.IndexLocation.GetDirectory(), task.IndexOptions.RecreateIndex));
                    services.Add(service);
                }

                // process the task
                task.Execute(service);
            }
            using (var searchService = new SearchService(indexSearcher))
            {
                var query = new ProductQuery().WithKeywords("喜欢");// WithPriceBetween(0, 100);
                var result = searchService.SearchIndex(query.Query);
                foreach (var doc in result.Results)
                    Console.WriteLine(doc.GetValue("name"));


                Console.ReadLine();
            }
Please tell me the reason! Thanks!

Mavin