Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p8i4x-0007vm-U1 for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Dec 2022 13:27:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p8i3x-000735-6S for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Dec 2022 13:26:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p8i3w-00072w-3j for pgsql-hackers@lists.postgresql.org; Fri, 23 Dec 2022 13:26:12 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p8i3r-0000qr-0q for pgsql-hackers@lists.postgresql.org; Fri, 23 Dec 2022 13:26:11 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 15BA9320024A; Fri, 23 Dec 2022 08:26:03 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 23 Dec 2022 08:26:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1671801962; x=1671888362; bh=T UxdKpRGnSdhrNGL5FTMsg/Ism2dDqxnZay5jSFPFZs=; b=T9WUOuKES4PXBFcEO js2RZcIyIuUqL0XsMbFlIn/HbOMFRt4bjS9jyM+dfv2U2Ff8XzIy/KO/4ALN6Lv7 e98OSgfToYnpY0u74aYcOCEKlPa8EJocLFM70YZfQKQ25If5tbQV3ehTV14EbXk3 U6fU7gVKDxTSIJ7hkvnEFWHG+GGZicgTanicUuG30LSyO+8NxrOIkBY115LWGGfV jQXdMlc8mExo21BJVlQGr9zyLyVZsNIO0Q0/acotUE4vG1DScDdv4yMlGcOohs2o NYXmkJr6ZkYBHjLbltSP/8IMcEogqUwQuN7yT+NE4ZfI67XnTczO0prtqPFt3e4z DXcDQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrhedvgdehvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpeefteekgefggfeiveekueeiudejheeludffueduhffgtddv ffffkeektefguedvfeenucffohhmrghinhepsghisghlihhothgvtggruggvnhhomhgsrh gvshdrtghomhdpvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnh hoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 23 Dec 2022 08:26:01 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 0B97CE9A; Fri, 23 Dec 2022 14:26:00 +0100 (CET) Date: Fri, 23 Dec 2022 14:25:59 +0100 From: Alvaro Herrera To: Dag Lem Cc: PostgreSQL Hackers Subject: Re: daitch_mokotoff module Message-ID: <20221223132559.mauqerlf75d7jnuq@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221223130747.ymxv7gbj6kr7vwrh@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Dec-23, Alvaro Herrera wrote: > I wonder why do you have it return the multiple alternative codes as a > space-separated string. Maybe an array would be more appropriate. Even > on your documented example use, the first thing you do is split it on > spaces. I tried downloading a list of surnames from here https://www.bibliotecadenombres.com/apellidos/apellidos-espanoles/ pasted that in a text file and \copy'ed it into a table. Then I ran this query select string_agg(a, ' ' order by a), daitch_mokotoff(a), count(*) from apellidos group by daitch_mokotoff(a) order by count(*) desc; so I have a first entry like this string_agg │ Balasco Balles Belasco Belles Blas Blasco Fallas Feliz Palos Pelaez Plaza Valles Vallez Velasco Velez Veliz Veloz Villas daitch_mokotoff │ 784000 count │ 18 but then I have a bunch of other entries with the same code 784000 as alternative codes, string_agg │ Velazco daitch_mokotoff │ 784500 784000 count │ 1 string_agg │ Palacio daitch_mokotoff │ 785000 784000 count │ 1 I suppose I need to group these together somehow, and it would make more sense to do that if the values were arrays. If I scroll a bit further down and choose, say, 794000 (a relatively popular one), then I have this string_agg │ Barraza Barrios Barros Bras Ferraz Frias Frisco Parras Peraza Peres Perez Porras Varas Veras daitch_mokotoff │ 794000 count │ 14 and looking for that code in the result I also get these three string_agg │ Barca Barco Parco daitch_mokotoff │ 795000 794000 count │ 3 string_agg │ Borja daitch_mokotoff │ 790000 794000 count │ 1 string_agg │ Borjas daitch_mokotoff │ 794000 794400 count │ 1 and then I see that I should also search for possible matches in codes 795000, 790000 and 794400, so that gives me string_agg │ Baria Baro Barrio Barro Berra Borra Feria Para Parra Perea Vera daitch_mokotoff │ 790000 count │ 11 string_agg │ Barriga Borge Borrego Burgo Fraga daitch_mokotoff │ 795000 count │ 5 string_agg │ Borjas daitch_mokotoff │ 794000 794400 count │ 1 which look closely related (compare "Veras" in the first to "Vera" in the later set. If you ignore that pseudo-match, you're likely to miss possible family relationships.) I suppose if I were a genealogy researcher, I would be helped by having each of these codes behave as a separate unit, rather than me having to split the string into the several possible contained values. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "Industry suffers from the managerial dogma that for the sake of stability and continuity, the company should be independent of the competence of individual employees." (E. Dijkstra)