And with Solr, say Solr 3.5 out of the box distro on the example/tutorial data, you can do this:
http://localhost:8983/solr/select?q=*:*&wt=velocity&v.template=count&v.template.count=$response.response.response.numFound
With the response being text/plain with value "17" (or however many documents there are) only. All Solr parameters such as q/fq and so on can be used however needed.
That little template can be saved in solr/conf/velocity/count.vm ("$response.response.response.numFound", sorry that's a lot of "response" object graph navigation, which is Solr's internal response object structure alas) and eliminate the v.template.count parameter. And a "/count" request handler could be mapped to make this super clean as http://localhost:8983/solr/count?q=*:*:
<requestHandler name="/count" class="solr.SearchHandler">
<lst name="defaults">
<str name="wt">velocity</str>
<str name="v.template">count</str>
<str name="v.contentType">text/plain</str>
<str name="rows">0</str>
</lst>
</requestHandler>
Sorry, didn't quite answer the question, but just wanted to show that implementing this with Solr is straightforward when/if needed.
Erik
On Mar 21, 2012, at 11:31 , Walter Lewis wrote:
> In the various bundles of good ideas that represent result set
> "standards" in the library and greater world, apart from the
> atom/opensearch <totalResults> element, is there an expectation of how
> one should package a number when that is *all* that is being
> requested?
>
> Use Case:
> dear dataset:
> if I asked you for "steamboat" records, how many would you send me?
> signed: curious
>
> dear curious:
> 12
> signed: dataset
>
> I'm inclined to return just the number as Content-Type: text/plain.
>
> Clearly the semantics of the query string require a mutual
> understanding, but that's not my specific concern here.
>
> Walter
|