The search of books and papers is a diligence of the Spanish Procedural Penal Law (in Spanish Ley de Enjuiciamiento Criminal, henceforth LECrim), then it is aimed to find a clue of a supposed crime, which may support an accusation during a trial (art. 299 LECrim). More precisely, this diligence consists in the search of a hint inside the books and papers destined to maintain a record of the accounts of the investigated (art. 573 LECrim).
In the practice, the search of books and papers is an accessory diligence, it usually is embedded in the search of a domicile, which is a diligence with a broader scope, since this latter diligence may be used not only to search in the books and papers of the investigated, for instance it can have as a goal the arrest of the suspect (art. 546 LECrim). Why then is the search of books and papers an autonomous diligence? Probably because the place where are hidden some important documents to the penal process is not always a domicile, and because the fundamental rights affected in both cases are different. If we need to get inside a domicile to find important papers or books, the fundamental right involved is the right to the inviolability of a domicile, but if we need to register a place which is not considered a domicile according to the law (art. 554 LECrim), the right harmed with this diligence is the right to the intimacy.
The difference between rights affected entails another consequence, if we read with calm the article 18.2 of the Spanish Constitution (henceforth, CE), where the right to the inviolability of the domicile is recognized, and the art. 18.1 CE where the right to the intimacy is stated, we find that in the latter the CE doesn’t contain an enumeration of the causes which may legitimate an intromission in this right. Indeed, we have another important instance in the art. 18.3, where is established the right to the inviolability of the communications, because we also find a reference to an exception which may authorize an intromission. In both articles, art. 18.2 or art. 18.3, the judicial authorization serves as a way to make legal an interference in the exercise of the rights guaranteed.
Therefore, do we need an judicial authorization to search the books a papers which are not in a domicile? A fast answer would say no. But a brooded answer would say yes, except in some cases. The right to the intimacy is a fundamental right, and as a fundamental right has an special protection, one of this protections according to our jurisprudence is a judicial resolution to authorize any intromission. But the above is only a general rule, and since the Constitution expressly doesn’t exige any requisite, the Spanish jurisprudence has gone further and has established an exception to the general rule. To be understood legal an intromission in the right to the intimacy guaranteed in the art. 18.1 of the CE has to concur three requisites:

  1. The existence of reasons of necessity: the existence of reasons for immediate policial intervention.
  2. A legal habilitation: The Spanish police is allowed to the practice of some diligences according to art. 282 LECrim and article 11.1 Ley Orgánica 2/1986, de 13 de marzo, de fuerzas y cuerpos de seguridad del Estado.
  3. The police has to comply with the principle of proportionality: the diligence has to be necessary to achieve a legitime constitutional goal, right to achieve this goal, and that the concrete way of control or inspection yields less sacrifices in the individual right than in the general interests.

Hence we can draw two conclusions from the above, the search of books and papers is an independent diligence which doesn’t need necessarily to be preceded by the search of a domicile, and the right to the intimacy as a general rule needs a judicial resolution to legitimate a intromission, but under determined conditions the police may interfere with the right to the intimacy without one.
When we talk about the search of books and papers, there are other considerations that we have to take into account. For instance, the occasional discoveries. An occasional discovery is a find which doesn’t enter into the purpose of the investigation, a good example is when the judicial resolution authorizes the register of a computer to find proofs of a crime of extortion, and during the investigation is also found proofs of a crime of minors´ pornography. In this cases the jurisprudence has admitted the validity of this occasional discoveries as proofs on the basis of the theory of the flagrant crime, which is a crime discovered by the police during its commission of soon after it.
Other thing we have to bear in our minds is the possibility offered by the article 575, which proclaims the existence of a duty of collaboration with the justice, in other words, everyone with documents helping the investigation has the obligation to share this information with the judge. When who has this information is the investigated, this obligation is diluted by the right to not auto incriminate oneself (art. 24.2 CE). Whereas when is the accusation who has this information, it has the obligation constitutionally declared to collaborate with the justice (art. 118 CE).
Therefore, the search of books and documents doesn’t need to be always carried out in a domicile, it doesn’t need to be always approved by judicial resolution, and it doesn’t need to obtain always proofs only related with the original investigation, being accepted by the jurisprudence the occasional discoveries.