About full-text searches

Build 1501 on 14/Nov/2017  This topic last edited on: 5/Aug/2014, at 13:53

Full-text searches use the special function fn:fullText(attributeExpr, searchExpr).

For example:

  gn4:story[fn:fullText(gn4:title, 'Obama')]

returns all stories containing the word ‘Obama’ anywhere in their title, and:

  gn4:story[fn:fullText(nav:text, 'Obama')]

returns all stories containing the word ‘Obama’ anywhere in the full-text indexed attributes.

fn:fullText() behaves like a  Boolean function returning true when the content of the attribute specified by the first argument matches the full-text search expression specified by the second argument (e.g. similar to the contains() function), but ‘under the hood’ it is translated in a full-text query executed by the full-text search engine installed with the system.

Due to this translation, the first argument of fn:fullText()must be the path of a full-text searchable object attribute, or the special path ‘nav:text’ indicating all the full-text indexed data.

The second argument must be either a string literal or a string variable specifying a valid search expression.

This means that these expression are NOT valid:

  fn:fullText(concat(gn4:title, gn4:authors), 'Obama')  -- WRONG

the first argument is a function call and not just the path of an object attribute;

  fn:fullText(gn4:title, gn4:authors)  -- WRONG

the second argument is a path and not a string literal or string variable;

  fn:fullText(gn4:title, 'Obama and')  -- WRONG

the second argument is not a correct search expression (see below).