public SimpleFacetedSearchInstance GetSimpleFacetedSearch(object folder, object groupByFields)
        {
            if (groupByFields == null || groupByFields == Null.Value || groupByFields == Undefined.Value)
            {
                throw new JavaScriptException(this.Engine, "Error", "Must specify the field(s) to group by as the second parameter.");
            }

            var groupByFieldsList = new List <string>();

            if (groupByFields is ArrayInstance)
            {
                groupByFieldsList.AddRange((groupByFields as ArrayInstance).ElementValues.OfType <string>());
            }
            else
            {
                groupByFieldsList.Add(groupByFields.ToString());
            }

            var targetFolder        = GetFolderFromObject(folder);
            var simpleFacetedSearch = LuceneHelper.GetSimpleFacetedSearch(targetFolder, groupByFieldsList.ToArray());

            return(new SimpleFacetedSearchInstance(this.Engine.Object.InstancePrototype, simpleFacetedSearch));
        }