You can create a map function like this:
function(doc) {
var key = [doc.from, doc.to].sort(function (a, b) {
return a.localeCompare(b);
});
emit(key.concat(doc._id), doc);
}
Then you will be able to get the conversation between users by querying '?startkey=["user1", "user2"]&endkey=["user1", "user2", {}]'. Of course both start- and endkeys 0 and 1 indexes should be alphabet-sorted.