Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xDgOf-00000000eHu-3As1 for pgsql-general@arkaria.postgresql.org; Mon, 05 Oct 2026 10:58:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xDgOe-00000009aDB-2rDk for pgsql-general@arkaria.postgresql.org; Mon, 05 Oct 2026 10:58:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xDgOe-00000009aD2-1Hoo for pgsql-general@lists.postgresql.org; Mon, 05 Oct 2026 10:58:16 +0000 Received: from mail-ej2-x0e.google.com ([2a00:1450:4864:34::e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xDgOc-00000000SUY-0e3y for pgsql-general@lists.postgresql.org; Mon, 05 Oct 2026 10:58:15 +0000 Received: by mail-ej2-x0e.google.com with SMTP id a640c23a62f3a-c2e7c1d9202so183701866b.3 for ; Mon, 05 Oct 2026 03:58:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791197892; x=1791802692; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=/nsW0p/GZa+1duc7RSuREYnski8xsQcDx5xsinvGYbY=; b=C0LYlPl0uM0pt3jx95aGp1LC81KbFjA+o2i5QCuGakKLThnXiOYdeE7ipc7n5HqV1x ZVpyECvXd8lwv/ouRPhKB0z5qub+N8f79SjPjYOxwGL6/lDP2RTHEBcgaxeF+ThiCX97 VPXlzNog9nac2Hk3GKqOR6NWnLh7ZzAYB3Rbp++Hz+BXCT7PAinuawg2gkbJILlUbjA9 ZyGwWqk1Xam+6MOfz9oEUJErEWf9Zu3f/FeLYjAoK4nmD4Xj0LYdh2diPQ54yYFpHWQX ImQTzrPgS7TQkv/RTuu7vmaXbapH2aU0W7G9vAe2vHp0gSBJrI2jb5ACZavSyq9Grepb YUTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791197892; x=1791802692; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=/nsW0p/GZa+1duc7RSuREYnski8xsQcDx5xsinvGYbY=; b=LhAdCuoSrLIOz21Kw4qedvkEAZlqzYx+kjhgbdVzES7WKK4RxKwG5z0+tPMia1yYx6 Nd3AQJUwGB4/D1nHtCgTQp2n3e1gBF2EtpOPRk1JIk+Z7pjJv9WeuNtJGawQkJhtK8Pd z2Jr6JhI7OUSOzyxN3UykfAP7SaRtWRA48mGp87qOL4sh/27SU5OIcqpYzDdGX9JdlAL Ciel5hPDjWGhkikoqF/wmbNcgnRaUi9lV1hvPlQz0rHkSW5ofP8f9Qe0xKTebOkdnvKN 8yKDNId6So30UwqqH33Y9bwWFOzIHBEPQI/oO/fA0cFjrVBnp9ExnlsL0uSghvWCj1Fb XlVQ== X-Gm-Message-State: AFuF++kr3oVLXmNFYPzMxylZ/PNe2NHY9OIPoRF8BofEIrvWU+0G1utq skYuVuzoAujZ8K7vm1JGmyfNKOvwHdD0V6T11gTLJuBRLhM1McmSTYDo X-Gm-Gg: AYBFou0WxQqcMe+Eznyr69WEql+SSayBmaaQtpYX763AfGJ+hguuW9WP1BDgaibWRBl q3tNTpgyqT3mX5zZTiChZehlBZohuJd7R6N1KrBiFsQP+WhXdf55uye3DfsgHEFCA3Pl+jHdwB8 u09Z+yOsRHaP6XhZdwU2mvMTXng91vfoqQE+yUE7QZUWosqEtyCVcj2JOsiiNUlg6uOME4QRUF9 yIfOpQnbIUIWx/BfpG/3ySOzcC0gXOWYGaNZAps9Rf8rWfh8ronUdRLt7W+OwWtrwKwL+BRigbc FV1LOVtC982P4Y8ZOFvUDggUH2IwvNaUsEdiYK1LJUkFvJ8ZxBl8BZIiD74IFg16bRBhHH0zYxv FuCsmTz02LIq6jmF5WYekvGoJM7TfE2gNCgNk5jsukcArEbFKGSzue0w9hpkGStrU9GHcpt4g0a kJwjVVw7mWW1MHBWhMP0EqbeblziuKVrfvmpVJrzRk+OULs8ixXgjuwBE2HnY+O6iKVLZKM84/I 2O7p71IJQyQiwI/bNnAe4tko8xC5jlZh+EZT1ATFBBzphlYy4VhV5Q0NXAtC9wgWogk8g== X-Received: by 2002:a17:907:8e87:b0:c2d:d71c:c2cc with SMTP id a640c23a62f3a-c2e4b262d62mr857291766b.48.1791197892227; Mon, 05 Oct 2026 03:58:12 -0700 (PDT) Received: from smtpclient.apple (84-104-229-211.cable.dynamic.v4.ziggo.nl. [84.104.229.211]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c3156360832sm57791066b.75.2026.10.05.03.58.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Oct 2026 03:58:11 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.700.51.1.1\)) Subject: Re: Parsing of hex encoding strings From: Thomas de Zeeuw In-Reply-To: <088bd47f443ee4b8f657e3dbfadf611a560aa95d.camel@cybertec.at> Date: Mon, 5 Oct 2026 12:58:01 +0200 Cc: pgsql-general@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <088bd47f443ee4b8f657e3dbfadf611a560aa95d.camel@cybertec.at> To: Laurenz Albe X-Mailer: Apple Mail (2.3864.700.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Larenz, Thank you for your response. Not great that the first thing I read that = this a design error, especially since you=E2=80=99re not familiar with = the entire system. In any case, allow me to expand on why we do it this = way. We have various columns that we want to search, most of them are English = text (or at least some kind of human language). However, one of them is = a public key encoded as a hex string. We want to search all those = columns in single query and since most of them are English text we = decided on full text search. We imagined one of the words in the search = vector would simply be the hex encoded public key. This actually works = pretty well for our use case, with the exception of the case I=E2=80=99ve = described in the original email. The trigram search doesn=E2=80=99t work well for the English text = columns we have. We could do the trigram search just for the hex encoded = public key, but we thought it would return too many false positives = given that we=E2=80=99re only interested in exact and prefixed matches. = The similarity searching property of trigrams would be negative here as = we could include public keys that=E2=80=99s we're not searching for. We=E2=80=99ll resort to converting the hex encoded public key to a = vector/query by casting instead of using the various functions for this. > On 5 Oct 2026, at 12:35, Laurenz Albe = wrote: >=20 > On Mon, 2026-10-05 at 11:50 +0200, Thomas de Zeeuw wrote: >> I=E2=80=99m working on a system where I need to search for hex = encoded strings, for >> which I=E2=80=99m using full text search with the =E2=80=9Csimple=E2=80= =9D directory. This is working >> fine for the most part, but I=E2=80=99ve run into an issue which may = or may not be >> considered a bug. >>=20 >> When creating the ts vector and queries I want to achieve that the = entire hex >> encoded string is seen as a single word. For a string such as = =E2=80=9Cfe82fbb28=E2=80=9D >> this works using the =E2=80=9Csimple=E2=80=9D directory. However a = string such as =E2=80=9C7e82fbb28=E2=80=9D >> is parsed as two words: =E2=80=9C7e82=E2=80=9D as scientific notation = and =E2=80=9Cfbb28" as numword. >> I=E2=80=99ve put the output of ts_debug at the bottom of this email = for convince. >>=20 >> I would have expected that the entire string would be considered as = one token >> considering it doesn=E2=80=99t have any whitespace. And since that = token isn=E2=80=99t a valid >> scientific number as whole (though it can be, just not the examples = I=E2=80=99ve >> shared above) I would expected it be considered a single word = (numword). >> Reading the URL example from chapter 12.5 >> (https://www.postgresql.org/docs/current/textsearch-parsers.html) = maybe it >> could have to two tokens, one for the scientific number (=E2=80=9C7e82=E2= =80=9D) and another >> numword token for the entire string (7e82fbb28=E2=80=9D), this would = also work for my >> use case. >>=20 >> Finally, my question: is this considered behaviour a bug or working = as intended? >=20 > That is working as intended. The problem is that you are trying to = use full-text > search for something that isn't a text. Storing strings in hex = encoding was a > design error. Not only does it keep you from using full-text search, = but you > are also wasting storage space (unless TOAST compression takes care of = that). >=20 > You could use substring search with pg_trgm, but it is not the same as > full-text search. >=20 > Yours, > Laurenz Albe