X-Query for retrieving parts of an element

Given the following XML doc stored in Tamino :


Text

…Text1…
…Text2…
…Text1…



Text

…Text3…
…Text1…



I’d like to write a full-text query in all sub-element of to search the text “Text1”. The result I’d like to obtain is :


Text

…Text1…
…Text1…



Text

…Text1…



With X-Query, I managed to only retrieve elements, and I loose reference to attribute ID of the element.

With QuiP, I managed to obtain a document like this :


Text

…Text1…



Text

…Text1…



Text

…Text1…



I used XYZFind database and the query language permits to retrieve results like that. Is there a way in Tamino to get such query results ?

A little remark at first

When quering documents, Tamino X-Query can’t retrieve only those elements which contain “Test1”. The result will contain both of your documents just like they have been stored in Tamino.


Text

…Text1…
…Text2…
…Text1…



Text

…Text3…
…Text1…



If you query elements directly, each element in result will be accompanied with ino:id attribute. This can tell you which document element belongs to. May be ino:id attribute could replace your own identifiers?

To receive result in the form you want, some transformation must be performed.

QuiP could do this but it hasn’t been implemented on database level yet (let’s wait for the next version).

Another partial solution is Tamino XSLT Server Extension. Of course it doesn’t limit size of documents returned by Tamino but it helps you to save network traffic between a client application and Tamino Server, because all calls are local.

Hi Sollan,

The following seemed to work using Quip … (there might be better ways - I’m a newbie at Quip)

for $aaa in collection(“ino:etc”)/AAA
return
{$aaa/@ID}
{$aaa/BBB}

{$aaa/CCC/DDD[.="…Text1…"]}



Using X-Query, you could get the AAA element as well as the matching DDD elements in the same query using the following:

AAA/@ID[//DDD~=“Text1”]|//DDD[.~=“Text1”]

This would return the following:
xql:result

…Text1…
…Text1…

…Text1…
</xql:result>

The result set would not maintain the element hierarchy, but you could depend on the order of the elements (or the ino:id) to get the matching ID.

Hope this helps…

Regards,
Puny

Thanks for the replies.

If I want from now on search in all sub-elements of the text “Text1” (case-insensitive), with a full text query, it should be like this in QuiP :

QUERY A :
------------
for $aaa in collection(“ino:etc”)/AAA
return
{$aaa/@ID}
{$aaa/BBB}

{$aaa/CCC/DDD[lower-case(string(.))=lower-case(“Text1”)]}



This query is much slower than the X-Query Full Text search :

QUERY B :
------------
AAA/@ID[//DDD~=“Text1”]|//DDD[.~=“Text1”]

On the other hand, using the last query, I can’t retrieve with X-Query more than 2 types of element (here : AAA and DDD). If I try to retrieve in supplement BBB elements, I get only results from 1 AAA element :

QUERY C :
------------
AAA/@ID[//DDD~=“Text1”]|//DDD[.~=“Text1”]|AAA/BBB[//DDD~=“Text1”]

So my dilemma is :
- with QuiP, it’s possible to write the query, but the processing time is too long ; moreover QuiP is not implemented on the database side.
- with X-Query implemented in Tamino, I can get the result quickly, but only a part of it.

Questions :
- Is there any other way in Tamino to get such query results ?
- When the next version of Tamino will be out ?

I checked query C in Tamino 3.1.2 and it works as you wish. Both elements are returned.

Though I excepted that correct query should look a little bit different.

AAA[//DDD~=“Text1”]/@ID|//DDD[.~=“Text1”]|AAA[//DDD~=“Text1”]/BBB

I am surprised that they both give the same result, because // means descends or self in XPath specification and there is no element under

OK Alexander,

All is working now

I used the Interactive Interface to launch the query on my big real document stored in Tamino, and the result size was too small to display all the results. (oops :rolleyes: )

Thanks a lot !

Regards,

Sollan