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(); }
public async Task Reindex() { await ItemSearchRepository.RunIndexerAsync(); }
// GET: Search public async Task <ActionResult> Index(string q) { var results = await ItemSearchRepository.SearchAsync(q); return(View(results)); }