Re: possible to create multivalued index from xpath() results in 8.3?

From: "Matt Magoffin" <postgresql(dot)org(at)msqr(dot)us>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: possible to create multivalued index from xpath() results in 8.3?
Date: 2007-11-19 19:00:31
Message-ID: 53241.192.168.1.108.1195498831.squirrel@msqr.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

> "Matt Magoffin" <postgresql(dot)org(at)msqr(dot)us> writes:
>> 2) Even if I could have an xpath() result return an array with multiple
>> values, like {value1,value2,value3} I wasn't able to define a GIN index
>> against the xml[] type. Should this be possible?
>
> Dunno about your other questions, but the answer to this one is "no"
> --- AFAICS there is no indexing support of any kind for the xml type
> in 8.3. Try casting to text[] instead.

I had tried that, but it does not actually work because of my first issue,
of a way for the XPath to return 3 individual text nodes. If I return 3
elements, like

/elem[(at)key="mykey"] => {
<elem key="mykey">value1</elem>,
<elem key="mykey">value2</elem>,
<elem key="mykey">value3</elem>
}

and cast that to text[], I get 3 XML strings, including the <elem></elem>.
I want only the element text content.

Should the xpath() function return 3 individual text nodes like this:

/elem[(at)key="mykey"]/text() => {
value1,
value2,
value3
}

rather than concatenating these into a single text node result? I also
tried something like

string(/elem[(at)key="mykey"])

but that throws an XPath error. It looks like the code is converting this
to /x/string(/elem[(at)key="mykey"] internally, which is not a valid XPath.

So if xpath() cannot return individual text node results, would a possible
solution be to write a trigger function that generates a tsvector from the
XML array, and then use text search to locate matches?

-- m@

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kynn Jones 2007-11-19 19:36:21 Foreign keys and inheritance
Previous Message Josh Harrison 2007-11-19 18:53:22 Re: postgresql storage and performance questions

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2007-11-19 19:16:32 Re: VACUUM/ANALYZE counting of in-doubt tuples
Previous Message Tom Lane 2007-11-19 18:37:48 Re: [HACKERS] fulltext parser strange behave