/// <summary> /// Gets the solr parameters for collapse-expand queries /// </summary> /// <param name="options"></param> /// <returns></returns> public static IEnumerable <KeyValuePair <string, string> > GetCollapseExpandOptions(CollapseExpandParameters options, Func <ISolrQuery, string> serializer) { if (options == null) { yield break; } var collapseValues = GetCollapseOptions(options).Select(x => x.Key + "=" + x.Value).ToArray(); yield return(KV.Create("fq", "{!collapse " + string.Join(" ", collapseValues) + "}")); foreach (var kv in GetExpandOptions(options.Expand, serializer)) { yield return(kv); } }
public static IEnumerable <KeyValuePair <string, string> > GetCollapseOptions(CollapseExpandParameters options) { if (options == null) { throw new ArgumentNullException("options"); } yield return(KV.Create("field", options.Field)); if (options.NullPolicy != null) { yield return(KV.Create("nullPolicy", options.NullPolicy.Policy)); } if (options.MinOrMaxField != null) { yield return(options.MinOrMaxField.Switch <KeyValuePair <string, string> >( min: x => KV.Create("min", x.Field), max: x => KV.Create("max", x.Field))); } }