Re: tsearch2 dictionary for statute cites - Mailing list pgsql-general

From Tom Lane
Subject Re: tsearch2 dictionary for statute cites
Date
Msg-id 17558.1236731084@sss.pgh.pa.us
Whole thread Raw
In response to tsearch2 dictionary for statute cites  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Responses Re: tsearch2 dictionary for statute cites  (Oleg Bartunov <oleg@sai.msu.su>)
Re: tsearch2 dictionary for statute cites  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Re: tsearch2 dictionary for statute cites  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Re: tsearch2 dictionary for statute cites  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-general
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> People are likely to search for statute cites, which tend to have a
> hierarchical form.  I'm not sure the prefix approach will work for
> this.  For example, there is a section 939.64 in the state statutes
> dealing with commission of a crime while wearing a bulletproof
> garment.  If someone searches for that, they should find subsections
> like 939.64(1) or 939.64(2) but not different sections which start
> with the same characters like 939.641 (the section on concealing
> identity) or 939.645 (the section on hate crimes).  A search for
> chapter 939 should return any of the above.

I think what you need is a custom parser that treats these similarly to
hyphenated words.  If I pretend that the dot is a hyphen I get matching
behavior that seems to meet all those requirements.

Unfortunately we don't seem to have any really easy way to plug in a
custom parser, other than copy-paste-modify the existing one which would
be a PITA from a maintenance standpoint.  Perhaps you could pass the
texts and the queries through a regexp substitution that converts
digit-dot-digit to digit-dash-digit?

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_toast_temp_xx AND pg_temp_xx SCHEMAS
Next
From: Piotre Ugrumov
Date:
Subject: Re: Enable user access from remote host