Re: possible to create multivalued index from xpath() results in 8.3?
От | Matt Magoffin |
---|---|
Тема | Re: possible to create multivalued index from xpath() results in 8.3? |
Дата | |
Msg-id | 53241.192.168.1.108.1195498831.squirrel@msqr.us обсуждение исходный текст |
Ответ на | Re: possible to create multivalued index from xpath() results in 8.3? (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: possible to create multivalued index from xpath() results in 8.3?
|
Список | pgsql-general |
> "Matt Magoffin" <postgresql.org@msqr.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[@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[@key="mykey"]/text() => { value1, value2, value3 } rather than concatenating these into a single text node result? I also tried something like string(/elem[@key="mykey"]) but that throws an XPath error. It looks like the code is converting this to /x/string(/elem[@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@
В списке pgsql-general по дате отправления: