Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

Some variants are returned when doing a catalog search and some aren't

$
0
0

I'm new to Commerce, and I'm having difficulty getting search to return product variants consistently. We're using Lucene Search on Commerce 12.4. I'm hoping someone can give me some hints, areas, or even some search terms that I can use to always get products and their variants. (It might just be an incomplete index for all I know.)

I have the following code in an API controller on my front-end project:

public string ProductSearch(string search)
{
    var market = _currentMarket.GetCurrentMarket();
    CatalogEntrySearchCriteria criteria = new CatalogEntrySearchCriteria
    {
        SearchPhrase = search,
        MarketId = market.MarketId,
        Locale = _languageResolver.GetPreferredCulture().Name
    };
    criteria.ClassTypes.Add("product");
    criteria.ClassTypes.Add("variation");
    SearchManager manager = new SearchManager(AppContext.Current.ApplicationName);
    ISearchResults results = manager.Search(criteria);
    return JsonConvert.SerializeObject(results.Documents);
}

If I send in the word "Planning" I get back all products and variants (the same products and variants that the Commerce Manager's Catalog Entry Search returns). If I send in the abbreviation "COMS", for example, I get back the products that have "COMS" in the name but none of the variants. In the Commerce Manager, that same search yields 13 results (3 products + 10 variants), but the API is only returning the 3 products. I thought being more specific would help, so with one of the products being something like "COMS PlusOne" I put "COMS+PlusOne" in the search query. I get that product back, but none of the variants, and there are 4 variants in the catalog.

It would be great to know if there is a setting for Lucene Search, or an initialization step that was missed somewhere that I haven't found in my online searches. Unfortunately we're not using Find so I can see what has been indexed, either.

Thank you!


Viewing all articles
Browse latest Browse all 6894

Trending Articles