Parsing of hex encoding strings - Mailing list pgsql-general

From Thomas de Zeeuw
Subject Parsing of hex encoding strings
Date
Msg-id CC9C0072-98AF-4014-820C-F65BAF575346@gmail.com
Whole thread
Responses Re: Parsing of hex encoding strings
List pgsql-general
Hello,

I’m working on a system where I need to search for hex encoded strings, for which I’m using full text search with the
“simple”directory. This is working fine for the most part, but I’ve run into an issue which may or may not be
considereda bug. 

When creating the ts vector and queries I want to achieve that the entire hex encoded string is seen as a single word.
Fora string such as “fe82fbb28” this works using the “simple” directory. However a string such as “7e82fbb28” is parsed
astwo words: “7e82” as scientific notation and “fbb28" as numword. I’ve put the output of ts_debug at the bottom of
thisemail for convince. 

I would have expected that the entire string would be considered as one token considering it doesn’t have any
whitespace.And since that token isn’t a valid scientific number as whole (though it can be, just not the examples I’ve
sharedabove) 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
scientificnumber (“7e82”) and another numword token for the entire string (7e82fbb28”), this would also work for my use
case.

Finally, my question: is this considered behaviour a bug or working as intended?


Output of ts_debug:

— Wanted result.
SELECT * FROM ts_debug('fe82fbb28');
+---------+--------------------------+-----------+--------------+------------+-------------+
|  alias  |       description        |   token   | dictionaries | dictionary |   lexemes   |
+---------+--------------------------+-----------+--------------+------------+-------------+
| numword | Word, letters and digits | fe82fbb28 | {simple}     | simple     | {fe82fbb28} |
+---------+--------------------------+-----------+--------------+------------+-------------+

— Unwanted scientific notation.
SELECT * FROM ts_debug('7e82fbb28');
+---------+--------------------------+-------+--------------+------------+---------+
|  alias  |       description        | token | dictionaries | dictionary | lexemes |
+---------+--------------------------+-------+--------------+------------+---------+
| sfloat  | Scientific notation      | 7e82  | {simple}     | simple     | {7e82}  |
| numword | Word, letters and digits | fbb28 | {simple}     | simple     | {fbb28} |
+---------+--------------------------+-------+--------------+------------+---------+

With kind regards,

Thomas de Zeeuw




pgsql-general by date:

Previous
From: "Carl.Weierstrass"
Date:
Subject: bug or feature
Next
From: Laurenz Albe
Date:
Subject: Re: Parsing of hex encoding strings