Esempio n. 1
0
        /// <summary>
        /// Executes the command
        /// </summary>
        public void Execute()
        {
            // Retrieve all companies from the database, index them, then release them from memory
            var companies = _unitOfWork.Companies.Fetch().ToList();

            foreach (var company in companies)
            {
                _searchProvider.Index(company);
            }

            companies = null;
            GC.Collect();

            // Retrieve all contacts from the database, index them, then release them from memory
            var contacts = _unitOfWork.Contacts.Fetch().ToList();

            foreach (var contact in contacts)
            {
                _searchProvider.Index(contact);
            }

            contacts = null;
            GC.Collect();

            // Retrieve all tasks from the database, index them, then release them from memory
            var tasks = _unitOfWork.Tasks.Fetch().ToList();

            foreach (var task in tasks)
            {
                _searchProvider.Index(task);
            }

            tasks = null;
            GC.Collect();
        }
 public static void CreateSampleIndex(ISearchProvider provider, string scope)
 {
     provider.Index(scope, "catalogitem", CreateDocument("12345", "sample product", "red", 123.23m, 2, new [] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Index(scope, "catalogitem", CreateDocument("sad121", "red shirt", "red", 10m, 3, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Index(scope, "catalogitem", CreateDocument("jdashf", "blue shirt", "blue", 23.12m, 8, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Index(scope, "catalogitem", CreateDocument("32894hjf", "black sox", "black", 243.12m, 10, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Commit(scope);
     provider.Close(scope, "catalogitem");
 }
 public static void CreateSampleIndex(ISearchProvider provider, string scope)
 {
     provider.Index(scope, "catalogitem", CreateDocument("12345", "sample product", "red", 123.23m, 2, new [] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Index(scope, "catalogitem", CreateDocument("sad121", "red shirt", "red", 10m, 3, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Index(scope, "catalogitem", CreateDocument("jdashf", "blue shirt", "blue", 23.12m, 8, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Index(scope, "catalogitem", CreateDocument("32894hjf", "black sox", "black", 243.12m, 10, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Commit(scope);
     provider.Close(scope, "catalogitem");
 }
        /// <summary>
        /// Submits the documents.
        /// </summary>
        /// <param name="scope">The scope.</param>
        /// <param name="documentType">Type of the document.</param>
        /// <param name="documents">The documents.</param>
        public void SubmitDocuments(string scope, string documentType, IDocument[] documents)
        {
            foreach (var doc in documents)
            {
                _search.Index(scope, documentType, doc);
            }

            _search.Commit(scope);
            _search.Close(scope, documentType);
        }
Esempio n. 5
0
        public virtual void PublishDocuments(string scope, IDocument[] documents)
        {
            foreach (var doc in documents)
            {
                _searchProvider.Index(scope, DocumentType, doc);
            }

            _searchProvider.Commit(scope);
            _searchProvider.Close(scope, DocumentType);
        }
Esempio n. 6
0
 public static void AddDocuments(ISearchProvider provider, string scope, string documentType, string catalog)
 {
     provider.Index(scope, documentType, CreateDocument(catalog, "type1", "12345", "sample product", "red", 2, "visible", -1, 1, new[] { new Price("USD", "default", 123.23m) }, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda1", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Index(scope, documentType, CreateDocument(catalog, "type1", "red3", "red shirt 2", "red", 4, "visible", -1, 1, new[] { new Price("USD", "default", 200m), new Price("USD", "sale", 99m), new Price("EUR", "sale", 300m) }, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda2", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Index(scope, documentType, CreateDocument(catalog, "type2", "sad121", "red shirt", "red", 3, "visible", -2, 2, new[] { new Price("USD", "default", 10m) }, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Index(scope, documentType, CreateDocument(catalog, "type2", "32894hjf", "black sox", "black", 10, "visible", -2, 2, new[] { new Price("USD", "default", 243.12m) }, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Index(scope, documentType, CreateDocument(catalog, "type3", "another", "black sox2", "silver", 20, "visible", -2, 2, new[] { new Price("USD", "default", 700m) }, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Index(scope, documentType, CreateDocument(catalog, "type3", "jdashf", "blue shirt", "Blue", 8, "visible", -2, 2, new[] { new Price("USD", "default", 23.12m) }, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
     provider.Index(scope, documentType, CreateDocument(catalog, "type3", "hhhhhh", "blue shirt", "Blue", 8, "hidden", -2, 2, new[] { new Price("USD", "default", 23.12m) }, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
 }
Esempio n. 7
0
        public static void CreateSampleIndex(ISearchProvider provider, string scope)
        {
            provider.RemoveAll(scope, "");
            provider.Index(scope, "catalogitem", CreateDocument("12345", "sample product", "red", new[] { new Price("price_usd_default", 123.23m) }, 2, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
            provider.Index(scope, "catalogitem", CreateDocument("red3", "red shirt 2", "red", new[] { new Price("price_usd_default", 200m), new Price("price_usd_sale", 99m), new Price("price_eur_sale", 300m) }, 4, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
            provider.Index(scope, "catalogitem", CreateDocument("sad121", "red shirt", "red", new[] { new Price("price_usd_default", 10m) }, 3, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
            provider.Index(scope, "catalogitem", CreateDocument("jdashf", "blue shirt", "Blue", new[] { new Price("price_usd_default", 23.12m) }, 8, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }, true));
            provider.Index(scope, "catalogitem", CreateDocument("32894hjf", "black sox", "black", new[] { new Price("price_usd_default", 243.12m) }, 10, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
            provider.Index(scope, "catalogitem", CreateDocument("another", "black sox2", "silver", new[] { new Price("price_usd_default", 700m) }, 20, new[] { "sony/186d61d8-d843-4675-9f77-ec5ef603fda3", "apple/186d61d8-d843-4675-9f77-ec5ef603fda3" }));
            provider.Commit(scope);
            provider.Close(scope, "catalogitem");

            // sleep for index to be commited
            Thread.Sleep(2000);
        }