query bts_contains to obtain attribute value
Posted in 2013
Topics: Storage & Space Management, SQL Development & Query Writing, Data Types & Schema Design, Platform-Specific Issues
Hi everybody.
I am looking the best way to retrieve an attribute value from a XML column
stored in lvarchar field.
I am using BTS datablade with the new parameter all_xmlattrs on index BTS just
like this:
create index mibts_idx on mitab1 (col2 bts_lvarchar_ops) using bts
(xmlpath_processing='yes', all_xmlattrs='yes') in sbspace;
And using the function bts_index_fields to retrieve the paths were indexed.
Obtaining:
/airplane
/airplane@callsign
/boat/name
/boat/name@reg
If I am looking for the value of "callsign" attribute ... how it would be the
correct SELECT statement through the bts_contains function???
I am using:
SELECT COL2 FROM MITAB1 WHERE bts_contains(col2,'/airplane@callsign');
But the query returns "no rows foud"... do you know what I am doing wrong????
SUSE LINUX Enterprise 11
IDS 12.10.FC1
Thanks for ur attention.
Hi Tatiana,
> SELECT COL2 FROM MITAB1 WHERE bts_contains(col2,'/airplane@callsign');>
> But the query returns "no rows foud"... do you know what I am doing wrong????
It looks like the index is created properly so that you can search for
documents based on a given value of an attribute. In BTS, each tag or
attribute is indexed as a field in CLucene. To search for a specific value in
a given field, you need to use the syntax:
field:word
For example, if you want to search for an airplane with a callsign ABCD, this
is what the query would look like:
SELECT COL2 FROM MITAB1 WHERE bts_contains(col2,'/airplane@callsign:abcd');
You can also search for alternates either by:
SELECT COL2 FROM MITAB1 WHERE bts_contains(col2,
'/airplane@callsign:abcd or /airplane@callsign:wxyz');
or
SELECT COL2 FROM MITAB1 WHERE bts_contains(col2,
'/airplane@callsign:(abcd or wxyz)');
This select will return the entire document that has the specified callsign(s)
As BTS is an index, it cannot extract the callsign values from the document,
only index them. If you want to extract values from an xml document, you need
to look at the xmltransform() function provided with the Informix Server.
Mark Ashworth
IBM Informix Extensibility Architect
Email: ashworth@ca.ibm.com
Hola Tatiana.
Try this:
{ Table "informix".tab1 row
size = 56 number of columns = 1 index size = 0 }
create table "informix".tab1
( col2 text
) extent size 16 next size 16 lock mode
row;
revoke all on "informix".tab1
"public" as "informix";
<personal> <person
id='Jason.Ma'> <name> <family>Ma</family>
<given>Jessica</given> </name> </person> </personal>
SELECT extract(col2,
'/personal/person[@id="Jason.Ma"]/name/given') FROM tab1;
> To: ids@iiug.org
> From: jessytapoli@hotmail.com
> Subject: query bts_contains to obtain attribute value [30312]
> Date: Tue, 21 May 2013 12:52:56 -0400
>
> Hi everybody.
>
> I am looking the best way to retrieve an attribute value from a XML column
> stored in lvarchar field.
>
> I am using BTS datablade with the new parameter all_xmlattrs on index BTS
just
> like this:
>
> create index mibts_idx on mitab1 (col2 bts_lvarchar_ops) using bts
> (xmlpath_processing='yes', all_xmlattrs='yes') in sbspace;>
> And using the function bts_index_fields to retrieve the paths were indexed.
> Obtaining:
>
> /airplane
> /airplane@callsign
> /boat/name
> /boat/name@reg
>
> If I am looking for the value of "callsign" attribute ... how it would be the
> correct SELECT statement through the bts_contains function???
>
> I am using:
>
> SELECT COL2 FROM MITAB1 WHERE bts_contains(col2,'/airplane@callsign');>
> But the query returns "no rows foud"... do you know what I am doing wrong????
>
> SUSE LINUX Enterprise 11
> IDS 12.10.FC1
>
> Thanks for ur attention.
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>