Ejemplo n.º 1
0
 public async Task <ActionResult> AutoComplete(string prefix)
 {
     return(new JsonResult
     {
         JsonRequestBehavior = JsonRequestBehavior.AllowGet,
         Data = await ItemSearchRepository.SuggestAsync(prefix)
     });
 }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // have to init DB & Collection here, else when Search tries to init it will fail because DocumentDB resources aren't there
            Database db = DocumentDBRepository <Item> .GetOrCreateDatabase(DocumentDBRepository <Item> .DatabaseId);

            DocumentCollection col = DocumentDBRepository <Item> .GetOrCreateCollection(db.SelfLink, DocumentDBRepository <Item> .CollectionId);

            // uncomment to force reset and reload
            // ItemSearchRepository.DeleteAll().Wait();
            ItemSearchRepository.SetupSearchAsync().Wait();
            ItemSearchRepository.RunIndexerAsync().Wait();
        }
Ejemplo n.º 3
0
 public async Task Reindex()
 {
     await ItemSearchRepository.RunIndexerAsync();
 }
Ejemplo n.º 4
0
        // GET: Search
        public async Task <ActionResult> Index(string q)
        {
            var results = await ItemSearchRepository.SearchAsync(q);

            return(View(results));
        }