Thread: FW: indexing functions

FW: indexing functions

From
Bas Peters
Date:
I posted this message a while ago, but did not receive any response, so
I give it another try. Any pointer would help.

> Is it possible to manipulate the way an index is created by using
> functions? I would like to store SGML data in text fields that include
> a lot of entities (like ü). To enable the user to search the
> ü character as u I would like to index those entities as the
> character without the diacritical marks. Is this possible?
>
> Thanks in advance,
>
> Bas Peters
> bpeters@idc.nl

Re: [SQL] FW: indexing functions

From
"Gene Selkov Jr."
Date:
> > Is it possible to manipulate the way an index is created by using
> > functions?

Yes, it is possible:

\h create index
Command: create index
Description: construct an index
Syntax:
        CREATE [UNIQUE] INDEX indexname ON class_name [USING access_method]
( attr1 [type_class1], ...attrN | funcname(attr1, ...) [type_class] );
                                  ^^^^^^^^^^^^^^^^^^^^

You are responsible for providing the function in any acceptable form
(the only one I am familiar with is a c-coded shared object)

> > I would like to store SGML data in text fields that include
> > a lot of entities (like ü). To enable the user to search the
> > ü character as u I would like to index those entities as the
> > character without the diacritical marks. Is this possible?

Not without the transformation you apply before indexing. It could be
a user-defined function called from the CREATE INDEX instruction
above, or any filter applied externally before the data are loaded to
postgres.

If the data you are talking about are just words with character
entities, it would be a reasonable investment to write a user-defined
function. If the goal is to be able to run queries related to the
structure of the SGML documents, these will have to be split into a
number of tables representing their structure (assuming all records
adhere to the same model), and at this point, character filters can
also be applied. The records themselves will have to be stored as
blobs in a postgres database or as individual files outside.

--Gene