Try our conversational search powered by Generative AI!

Episerver Find using multiple categories

Vote:
 

Hi,

We have created an Episerver Find control and using custom checkbox categories we were hoping to Tag news articles with multiple categories. Using basic Episerver find c# code we have constructed something that works quite well apart from splitting up the multiple categories, it seems to display the multiple choices as one entry.

Is there any multi chice control that we should use that would allow us to categorise one page with multiple categories?

Thanks

 

#65762
Feb 07, 2013 16:36
Vote:
 

Hi!

Find can certainly help you search for pages in on or several categories. It can also be used to retrieve a list of categories and count the number of pages in each using facets. Find however doesn't do much (anything really :-)) in terms of web forms controls, so perhaps you could post a bit more about what you are trying to achieve?

#65763
Feb 07, 2013 22:20
Vote:
 

Hi,

We are using a PropertyCheckboxlist control in the CMS which allows the user to select multiple categories for a News article. Of course. Episerver saves multiple selected items in a single string, such as "announcements,posts,greetings".

When using the Facets in Find it uses this one large string as a single Facet. So we thought about splitting the string up using the commas. This works ok if there are multiple selected items in the string and that each News articles have different results, but if two or more News articles have just a single Facet such as "announcements" or have duplicate strings Find distincts this into one single instance so our loop doesnt work how we want it to.

So, my question is how would we set up the CMS to allow the user to select multiple categories, obviously the PropertyCheckboxlist control is the wrong way to go about it. We had thought about using the existing Categories tab in the CMS but our client has hundreds of categories which are used across the entire site and the News section only has a selected few.

I hope this makes sense. It's quite difficult explaining what I need :).

 

Thanks for your patience

#65844
Feb 12, 2013 10:31
Vote:
 

Hi!

I'm not sure I follow you on this: "but if two or more News articles have just a single Facet such as "announcements" or have duplicate strings Find distincts this into one single instance so our loop doesnt work how we want it to." Any other way to describe it? :)


In general, if you have a property with string containing comma separated values I would add another, code only, property that splits it and returns a collection of strings, ie:

public IEnumerable<string> CategoriesList
{
  get 
  {
    if(Categories == null) 
      return Enumerable.Empty<string>();

    return Categories.Split(',');
  }
}

After re-indexing you can the retrieve a facet for categories using .TermsFacetFor(x => CategoriesList)   

#65857
Feb 12, 2013 13:20
Vote:
 

HI,

We have this working now but we have stumbled across something weird. We have 12 categories, all of which have been assigned to pages so we would expect to see all the categories in the facets area yet only 10 are showing. If we unassign one of the showing facets one of the hidden ones are shown.

Is there a limit to the number of facets shown on the page?  If we do a count on the results it comes back with 76 TotalMatching yet when we loop the results it only shows ten.

Here is some of the code that we use:

 query = query.Filter(x => x.LanguageID.Match("en-GB"));

                var results = query.Select(x => new cSkills2S.Templates.PageTemplates.SearchResultHit
                {
                    Title = !string.IsNullOrEmpty(x.PageName.AsHighlighted()) ? x.PageName.AsHighlighted() : x.PageName,
                    Url = x.LinkURL ?? x.LinkURL,
                    Description = !string.IsNullOrEmpty(x.Summary.AsHighlighted()) ? x.Summary.AsHighlighted() : x.Summary,
                    CategoryOut = ""
                })
               // .Take(PageSize)
              //  .Skip((ActivePageNumber - 1) * PageSize)
                .GetResult();

    If we do a TotalMatching count it shows 76:

ItemCount = results.TotalMatching;

    If we do a simple loop it only shows 10:

foreach (var fct in results)
                        {
                            Response.Write(cou.ToString());

                            cou += 1;
                           
                        }

   Could you shine some light on this?

 

Many thanks

Jon

 

#74665
Edited, Sep 04, 2013 11:32
Vote:
 

By default, 10 is the max size of number of facets. To increase this, you could do this:

TermsFacetFor(x => x.Something, facet => facet.Size = 50)


As for the results count, use .Take() to increase it to more than 10.

http://find.episerver.com/Documentation/dotnet-api-pagination

#74666
Edited, Sep 04, 2013 12:06
Vote:
 

That's amazing - many thanks for your help.

#74667
Sep 04, 2013 12:13
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.