Exemplo n.º 1
0
        public void PerformSearch(SearchProvider provider)
        {
            SearchResults           epResults       = provider.Search();
            List <SearchResultItem> collectionItems = epResults.Items.FindAll((item) => { return(item.WrapperType == "collection"); });

            foreach (SearchResultItem item in epResults.Items.Except(collectionItems))
            {
                this.episodeList.Add(new FileMetaDataInfo(item));
            }

            if (collectionItems.Count > 0)
            {
                SearchResultItem seasonItem = collectionItems[0];
                this.seasonName = seasonItem.CollectionName;
                this.showName   = seasonItem.ArtistName;
                Regex seasonNumberMatcher = new Regex(@".*(\d).*");
                if (seasonNumberMatcher.IsMatch(seasonName))
                {
                    this.seasonNumber = int.Parse(seasonNumberMatcher.Matches(seasonName)[0].Groups[1].Value);
                }

                // Look for the 600x600 pixel artwork. This is a hack, and
                // may not work properly forever.
                this.DownloadArtwork(seasonItem.ArtworkUrl.Replace("100x100", "600x600"));
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var searchProvider = new SearchProvider();

            searchProvider.DeleteIndexIfItExists();

            searchProvider.CreateIndexWithWarmerAndAddData();
            Console.WriteLine("Added warmer when creating index");
            Console.ReadLine();

            searchProvider.AddWarmerToIndex();
            Console.WriteLine("Added warmer to index");
            Console.ReadLine();

            Console.WriteLine("search using warmer");
            Console.ReadLine();

            foreach (var item in searchProvider.Search("mph"))
            {
                Console.WriteLine("Animal: {0}, Speed in mph: {1}", item.AnimalName, item.SpeedDoubleMph);
            }

            searchProvider.DeleteWarmerFromIndex();

            Console.WriteLine("Deleted warmer from index");
            Console.ReadLine();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets a display object from the Examine cache or falls back the the database if not found
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="ProductDisplay"/>.
        /// </returns>
        protected override ProductDisplay GetDisplayObject(Guid key)
        {
            var criteria = SearchProvider.CreateSearchCriteria();

            criteria.Field(KeyFieldInIndex, key.ToString()).And().Field("master", "True");

            var display = SearchProvider.Search(criteria).Select(PerformMapSearchResultToDisplayObject).FirstOrDefault();

            if (display != null)
            {
                display.EnsureValueConversion(this._conversionType);
                return(display);
            }

            var entity = Service.GetByKey(key);

            if (entity == null)
            {
                return(null);
            }

            ReindexEntity(entity);

            return(this.ModifyData(entity.ToProductDisplay(this._conversionType)));
        }
        public JsonResult Search(string term)
        {
            var searchResults = new SearchResults {
                Results = _searchProvider.Search(term).ToList()
            };

            return(Json(searchResults.Results, "highlights", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public SearchResults RecipeSearch(AuthIdentity identity, RecipeQuery query)
        {
            if (SearchProvider == null)
            {
                throw new NoConfiguredSearchProvidersException();
            }

            return(SearchProvider.Search(identity, query));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the <see cref="ProductVariantDisplay"/> for a product
        /// </summary>
        /// <param name="productKey">
        /// The product key.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{ProductVariantDisplay}"/>.
        /// </returns>
        public IEnumerable <ProductVariantDisplay> GetVariantsByProduct(Guid productKey)
        {
            var criteria = SearchProvider.CreateSearchCriteria();

            criteria.Field(KeyFieldInIndex, productKey.ToString()).Not().Field("master", "True");

            var results = SearchProvider.Search(criteria);

            return(results.Select(x => this.ModifyData(x.ToProductVariantDisplay())));
        }
Exemplo n.º 7
0
        private void OnSearchButtonClick(object sender, RoutedEventArgs e)
        {
            this.resultsArea.Visibility = Visibility.Collapsed;
            string search = (this.searchBox.Text ?? string.Empty).Trim();

            if (search.Length == 0)
            {
                this.statusLabel.Text = "Please enter a search term to find or a longitude and latitude to navigate to.";
                return;
            }
            if (_provider.Search(search, this.SearchArea))
            {
                this.searchBtn.IsEnabled = false; // Only one search at a time
                this.statusLabel.Text    = "Searching...";
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Gets a product by it's slug.
        /// </summary>
        /// <param name="slug">
        /// The slug.
        /// </param>
        /// <returns>
        /// The <see cref="ProductDisplay"/>.
        /// </returns>
        public ProductDisplay GetBySlug(string slug)
        {
            var criteria = SearchProvider.CreateSearchCriteria();

            criteria.Field("slugs", slug).And().Field("master", "True");

            var display = SearchProvider.Search(criteria).Select(PerformMapSearchResultToDisplayObject).FirstOrDefault();

            // Don't modifiy the data here as it would have been modified in the PerformMapSearchResultToDisplayObject
            if (display != null)
            {
                return(display);
            }

            var key = _productService.GetKeyForSlug(slug);

            return(Guid.Empty.Equals(key) ? null : this.GetByKey(key));
        }
Exemplo n.º 9
0
        public override Item ResolveProductItem(params string[] arguments)
        {
            Assert.ArgumentNotNull(arguments, "arguments");
            Assert.IsNotNull(ShopContext, "ShopContext");
            var settings = ShopContext.GetBusinessSettings();

            string name = arguments[0];

            Assert.IsNotNullOrEmpty(name, "name");
            name = Sitecore.MainUtil.DecodeName(name);
            Item item = Sitecore.Context.Database.GetItem(settings.ProductsLink);

            Assert.IsNotNull(item, "Products root item cannot be null.");
            Query query = new Query
            {
                SearchRoot = item.ID.ToString()
            };

            query.AppendField(Sitecore.ContentSearch.BuiltinFields.AllTemplates, TemplateIDs.ProductBase.ToString(), MatchVariant.Exactly);
            query.AppendCondition(QueryCondition.And);
            query.AppendField("_name", name, MatchVariant.Exactly);
            return(SearchProvider.Search(query, Sitecore.Context.Database).FirstOrDefault());
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets a <see cref="ProductDisplay"/> by it's SKU.
        /// </summary>
        /// <param name="sku">
        /// The SKU.
        /// </param>
        /// <returns>
        /// The <see cref="ProductDisplay"/>.
        /// </returns>
        public ProductDisplay GetBySku(string sku)
        {
            var criteria = SearchProvider.CreateSearchCriteria();

            criteria.Field("sku", sku).And().Field("master", "True");

            var display = SearchProvider.Search(criteria).Select(PerformMapSearchResultToDisplayObject).FirstOrDefault();

            if (display != null)
            {
                return(this.ModifyData(display));
            }

            var entity = _productService.GetBySku(sku);

            if (entity == null)
            {
                return(null);
            }

            ReindexEntity(entity);

            return(this.ModifyData(AutoMapper.Mapper.Map <ProductDisplay>(entity)));
        }
Exemplo n.º 11
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     SearchProvider.Search(teKeyword.Text);
 }
 public async Task <IActionResult> Search(string queryTerm, int apiId)
 => Ok(await provider.Search(queryTerm, apiId));