tf:containsText bug / question

It seems Tamino have a bug with text
I did the following experiment, based on a local report:

for $a in input()/Establecimiento
where tf:containsText($a/DefinicionEstablecimiento/Nombre, “SAN”)
return $a/DefinicionEstablecimiento/Nombre

it returns (OK)
HOSP. SAN LUIS DE BUIN
CONS. SAN JOAQUIN
CONS. SAN BERNARDO

Later I did:

for $a in input()/Establecimiento
where tf:containsText($a/DefinicionEstablecimiento/Nombre, “SA”)
return $a/DefinicionEstablecimiento/Nombre

But returns no results !! :shock:

Originally I was trying to get some results with fn:starts-with, but it was a buggy function …

How can I emulate fn:starts-with ??

I have Tamino 4.4.1 WinXP Pro

Joe

Hi,

you did not encounter a bug, you just noticed correct behaviour of tf:containsText. This is a text retrieval function that searches for words and phrases. Apparently, there is no word “SA” in your database, so teh result is correct.
Obviously, you want to search for all Nombre element which contain words starting with “SA” at any position of the element content. In this case, you have to specify that you do not want to search for whole words but for their prefix only. In tf:containsText, you can do this using the * wildcard:


for $a in input()/Establecimiento 
where tf:containsText($a/DefinicionEstablecimiento/Nombre, "SA*") 
return $a/DefinicionEstablecimiento/Nombre 

This wildcard can also be applied at the beginning or in the middle of a word.
In your scenario, you will not find the names using “fn:starts-with()” - not because it is a buggy function, but simply because your element content DOES NOT start with “SAN”.
You might find the Tamino documentation helpful in explaining this in more depth

Regards

Harald

Thanks Harald
I’ll apply the wildcards for the containsText, but I did another test:

for $a in input()/Establecimiento
where tf:containsText($a/DefinicionEstablecimiento/Nombre, “H*”)
return $a/DefinicionEstablecimiento/Nombre

returns (OK)
HOSPITAL DE PRUEBA
HOSP. BARROS LUCO TRUDEAU
HOSP. EXEQUIEL GONZALEZ CORTES
HOSP. SAN LUIS DE BUIN

for $a in input()/Establecimiento
where fn:starts-with($a/DefinicionEstablecimiento/Nombre, “H”)
return $a/DefinicionEstablecimiento/Nombre

returns (BUG??)
HOSPITAL DE PRUEBA

for $a in input()/Establecimiento
where fn:starts-with($a/DefinicionEstablecimiento/Nombre, “HOSP.”)
return $a/DefinicionEstablecimiento/Nombre

returns no results !! :shock:

It seems a bug, that’s because I’m asking for some way to do starts-with with some tf:* function …

Joe

Hi Joe,

may I ask you to perform the following query:


for $a in input()/Establecimiento where tf:containsText($a/DefinicionEstablecimiento/Nombre, "H*") return substring($a/DefinicionEstablecimiento/Nombre,1,1)

If you get “H” four times, I agree that starts-with seems to have a bug

Regards

Harald

Harald
It’s really weird:

for $a in input()/Establecimiento where tf:containsText($a/DefinicionEstablecimiento/Nombre, "H*") return substring($a/DefinicionEstablecimiento/Nombre,1,1) 

returns

xq:valueH</xq:value>
<xq:value />
<xq:value />
<xq:value />
<xq:value />
<xq:value />
<xq:value />
<xq:value />
<xq:value />

:?:

Joe

Hi Joe,

actually, that is what I had expected. It seems that your Nombre elements contain some non-printable character in form of the “H”.
Please check with an editor that is capable of HEX display

Regards

Harald

Thanks Harald !

It was a data problem I’m going to fix right now

Joe