Specifying namespace for full text query

View: New views
3 Messages — Rating Filter:   Alert me  

Specifying namespace for full text query

by ashok _ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have xml documents which have a default namespace.

I have an XQuery script that runs a full text query on these documents.

Unfortunately I am having a problem with the syntax for prefixing the
namespace to the full text query :

I have the namespace declared like this :

declare namespace an = "http://www.akomantoso.org/1.0";

I have an array of collections which i want to run the search against :

let $search_scope :=
        (
                collection('/db/xmlcontent/debates')
                collection('/db/xmlcontent/documents')
        )

I build my search string like this :

let $search_string := concat('$search_scope', '//an:*[ft:query(.,
$search-for-this)]')

But this returns 0 results as I think the 'an' in the concat is being
treated like a string literal ...

I tried doing this instead :

let $search_string := concat('$search_scope', '//', an,
':*[ft:query(., $search-for-this)]')

But that returns an error ...

What is the right way to prefix the namespace for the above case ?

thanks in advance

Ashok

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Specifying namespace for full text query

by ashok _ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This syntax does not seem throw an error  :

let $an_nsdecl := 'declare namespace an="http://www.akomantoso.org/1.0"; '
.....
let $search_string := concat($an_nsdecl, '$search_scope' ,
'//an:*[ft:query(., $search-for-this)]')
let $hits := util:eval($search_string)

Unfortunately it doesnt return any results ... when i remove the
namespace entirely and also remove the default namespace from the
document ... the search works ...

What am i doing wrong ?

thanks

Ashok


On Thu, Oct 29, 2009 at 2:36 PM, ashok _ <listmanster@...> wrote:

> I have xml documents which have a default namespace.
>
> I have an XQuery script that runs a full text query on these documents.
>
> Unfortunately I am having a problem with the syntax for prefixing the
> namespace to the full text query :
>
> I have the namespace declared like this :
>
> declare namespace an = "http://www.akomantoso.org/1.0";
>
> I have an array of collections which i want to run the search against :
>
> let $search_scope :=
>        (
>                collection('/db/xmlcontent/debates')
>                collection('/db/xmlcontent/documents')
>        )
>
> I build my search string like this :
>
> let $search_string := concat('$search_scope', '//an:*[ft:query(.,
> $search-for-this)]')
>
> But this returns 0 results as I think the 'an' in the concat is being
> treated like a string literal ...
>
> I tried doing this instead :
>
> let $search_string := concat('$search_scope', '//', an,
> ':*[ft:query(., $search-for-this)]')
>
> But that returns an error ...
>
> What is the right way to prefix the namespace for the above case ?
>
> thanks in advance
>
> Ashok
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Specifying namespace for full text query

by Adam Retter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just some syntax mistakes, I have added corrections -

> let $search_scope :=
>        (
>                collection('/db/xmlcontent/debates')
>                collection('/db/xmlcontent/documents')
>        )

let $search_scope := '
        (
                collection('/db/xmlcontent/debates'),
                collection('/db/xmlcontent/documents')
        )'

NOTE - the comma between the collection functions and the quotes


> I build my search string like this :
>
> let $search_string := concat('$search_scope', '//an:*[ft:query(.,
> $search-for-this)]')

let $search_string := concat($search_scope, '//an:*[ft:query(., '
$search-for-this, ')]')

NOTE the changes to the quotes




--
Adam Retter

eXist Developer
{ United Kingdom }
adam@...
irc://irc.freenode.net/existdb

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open