The way the Search API is designed, you can't include values that have a frequency of 0 in the result set in your facet output. I don't think we would want to change that for a number of reasons, one of which is that building the entire list of possible facet values for every result set could get quite expensive, epecially as the number of facets grows.
But...if you're on ML6?...an easy way to do that would be to use the new search:values() function to build your base facet control widget, then just update the number with the search results on each call. If you're not on ML6, you can pretty easily do the same using lexicon functions like cts:element-values and cts:element-attribute-values. --Colleen ________________________________ From: [email protected] [[email protected]] on behalf of [email protected] [[email protected]] Sent: Thursday, July 18, 2013 3:43 PM To: [email protected] Subject: Re: [MarkLogic Dev General] Return 0 Count Facet Rows I did this. The constraints come back as I had passed them in, but the results still omit the index entries that have a count of 0. I just get the entries that return hits. From: [email protected] [mailto:[email protected]] On Behalf Of Danny Sokolsky Sent: Thursday, July 18, 2013 5:35 PM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Return 0 Count Facet Rows The way I can think of to do this is to use <return-constraints>true</return-constraints>, which will give you a list of all of the constraints. Then you can take all of the range constraints that are faceted and have some logic that looks through each faceted named constraint and, if there is no search:facet with that name, then make an entry with no content for that named constraint. My guess is it would take 10 or 20 lines of code to do that. -Danny From: [email protected]<mailto:[email protected]> [mailto:[email protected]] On Behalf Of [email protected]<mailto:[email protected]> Sent: Thursday, July 18, 2013 3:04 PM To: [email protected]<mailto:[email protected]> Subject: [MarkLogic Dev General] Return 0 Count Facet Rows I am using the search API to populate some data. I had the notion to use the facet results to drive the UI controls on the screen. Our business wants the controls to remain even if there are no results for a given facet item. However, when I start drilling down results, obviously there are 0 results for some of the items. Marklogic does not include those in the search response, which makes sense most of the time. However, I would like them to show up. How can I get it to pass back entries in the index that have a count of 0? Thanks
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
