public ActionResult Suggest(string text) { var indexManager = new ElasticSearchIndexManager(); var result = indexManager.Suggest(text); return(Json(result, JsonRequestBehavior.AllowGet)); }
public static void Execute() { // Get all the reservables dates (just a demo, eh?) List <Room> rooms; using (var context = new HotelReservationContext()) { rooms = context.Rooms .Include(room => room.Services) .Include(room => room.Reservations) .Include(room => room.SpecialPrices) .Include(room => room.Beds) .Include(room => room.Hotel) .ToList(); } //Apply business rules var engine = new RandomDiscountEngine(); engine.ApplyRules(rooms); //Reindex. I drop and recreate the index, beware the downtime var indexManager = new ElasticSearchIndexManager(); //Prepare documents (ReservableDateDocument here also acts a mapper/denormalizer) indexManager.UpdateIndex(rooms); }
public ActionResult Search(DateTime arrival, int nights, decimal?maxPrice = null, string text = null, string[] terms = null, int offset = 0) { var indexManager = new ElasticSearchIndexManager(); var result = indexManager.Search( arrival, nights, maxPrice, terms == null ? null : terms.Select(t => TermFilterDTO.FromString(t)), text, offset); return(Json(result, JsonRequestBehavior.AllowGet)); }