Joining documents and filter in couch ios client

	type: "item",
	id: 1,
	name: "test item",
	specs: [100, 200, 300],

	type: "spec",
	id: 100,
	name: "test spec",
	description: "test spec description",

There are about 50000 documents of type item and about 2000 documents of type spec. We don’t want to keep full details of spec in the item documents to minimize db size. So we are keeping only the spec ids in item documents.
We need to retrieve items which have a spec named ‘something’. Is there a way to join documents and write a query to get the results for this scenario.

“Join” is a relational concept; it doesn’t apply to map/reduce. In this case you’d run two queries: first to look up the spec by name, second to look up items with that spec ID. (Which is exactly what a relational database would do under the hood, if you gave it a join query.)

In an application what I’d suggest is referring to specs by Document reference instead of by name. That eliminates the need to query for the ID over and over.

1 Like

Thanks for your answer.