Sam Dutton
Sam Dutton

Reputation: 15269

Do 'reduce' with results from Cloudant search?

In Cloudant is it possible to do something like a reduce on a set of results from a search index (as opposed to a view)?

In my case, I'd like to find all documents that have a title value that includes 'foo', then for each of these sum the total number of views, based on each document's viewCount value.

Upvotes: 1

Views: 229

Answers (1)

bradnoble
bradnoble

Reputation: 75

You can't reduce but you can use faceting to get counts.

Example query ?q=*:*&counts=["type"]

Example response

{
  "total_rows":100000,
  "bookmark":"g...",
  "rows":[...],
  "counts":{
    "type":{
      "sofa": 10, 
      "chair": 100,
      "lamp": 97
    }
  }
}

https://docs.cloudant.com/search.html#faceting

Upvotes: 3

Related Questions