From: Jess Wren <jess.wren@interference.cc>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to use full-text search URL parser to filter query results by domain name?
Date: Sun, 7 Apr 2019 12:17:19 -0700
Message-ID: <a438ad2b-4eb2-3631-b1a6-d92ee085817e@interference.cc> (raw)
In-Reply-To: <wolfgang-1190407084206.A0129904@laptop.local>
References: <wolfgang-1190407084206.A0129904@laptop.local>
On 4/6/19 11:42 PM, hamann.w@t-online.de wrote:
> Hi,
>
> I have no real idea about solving the complete problem, and would probably try
> something with a temp table first.
> For extracting the hostname from a url you could use
>
> select regex_replace('https?://(.*=)/.*', '\\1', url)
>
> instead of the fulltext parser
>
> Best regards
> Wolfgang
Thanks Wolfgang, I understand that I could implement a function using
regex for this, or just create an extra column/table to store the
hostname data. But there are other parts of the application where I'll
need to extract URL path, others where i'll want to extract scheme, etc.
Since postgres has builtin capabilities for parsing URLs to do alll of
this, I'd rather just use the builtin functions instead of writing them
myself using regex or having to generate a temp table each time I do a
lookup.
So although I'm aware that there are a variety of ways to extract
hostname (right now I'm just doing it in Python), I'm really most
interested in understanding how to use the builtin Postgres URL parsers
to extract host, url path, etc and how to appropriately create indexes
based on them. The documentation for the URL parser is very sparse, and
I can't find much info online either.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: jess.wren@interference.cc
Subject: Re: How to use full-text search URL parser to filter query results by domain name?
In-Reply-To: <a438ad2b-4eb2-3631-b1a6-d92ee085817e@interference.cc>
References: <wolfgang-1190407084206.A0129904@laptop.local> <a438ad2b-4eb2-3631-b1a6-d92ee085817e@interference.cc>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox