---------- Forwarded message ----------
From: Roman Pastukhov <[email protected]>
Date: 2011/3/1
Subject: Re: [Sedna-discussion] i'd like like like search
To: Horn Gábor <[email protected]>


Hi,

If you need an expression that is similar to LIKE '%xxx%' in SQL, you
can use fn:contains
like this:
for $b in doc("doc")//book
where fn:contains($b/title/text(), "apple")
return $b

note that this code
 1. assumes that each book has one title element that contains text
without markup (you can probably use something like fn:concat, on a
nested FLWR to search some string among a set of strings, if that's
not acceptable)
 2. this search is case sensitive (you can use fn:lower-case on both
arguments, or use fn:matches with case-insensitive flag instead of
fn:contains)

full-text search can be used to achieve similar results
note that full-text search searches for words, not sub-strings like
fn:contains in XQuery or LIKE '%xxx%' in SQL

to do a query that searches books with titles containing word apple
you'll need to create index first:
CREATE FULL-TEXT INDEX "fti" ON doc("doc")//book/title TYPE "xml"

then you can search books like this:
ftindex-scan("fti", "apple")

note that if a book has title "Appleapple" it will be result of the
first query (one that uses contains) but not the second one
however, dtSearch supports wildcards, so you can do
ftindex-scan("fti", "*apple*") to search for all words that contain
"apple" as a sub-string.

to use full-text search in the current release version of Sedna you'll
need to buy dtSearch
next release of Sedna (which is expected during this spring) will also
contain support for native full-text indexes, but they won't support
wildcards in the nearest future. Native full-text indexes are also
available in the development version of Sedna.


2011/3/1 Horn Gábor <[email protected]>:
> Hello,
>
> i'm new to xnd systems and xquery, and after reading the documentation
> of sedna and playing a bit with it, it's not clear to me if i want to
> search in an xml document in a similar way like the rmdb "like"
> functionality, can that be achieved with sedna only or i need (to
> purchase) dtsearch as well?
>
> Eg i have a document
>
> <bookstore>
> <book>
> <title>Apples</title>
> </book>
> <book>
> <title>Oranges</title>
> </book>
> </bookstore>
>
> can sy please show me an  flwor expression which gives me back the book
> which has "apple" in it's title, something similar to "select * from
> books where title like '%apple%'? Would dtsearch just needed to produce
> this result in a more efficient way due to indexing, or it's straight
> impossible to do without it? I saw fn:ftcontains might be useful (and i
> think that's part of xquery) but i couldn't get that working with a
> flwor expression - but probably because i'm just starting to learn it.
> Can somebody enlighten me about it please?
>
> thanks, Gabor Horn
>
> ------------------------------------------------------------------------------
> Free Software Download: Index, Search & Analyze Logs and other IT data in
> Real-Time with Splunk. Collect, index and harness all the fast moving IT data
> generated by your applications, servers and devices whether physical, virtual
> or in the cloud. Deliver compliance at lower cost and gain new business
> insights. http://p.sf.net/sfu/splunk-dev2dev
> _______________________________________________
> Sedna-discussion mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sedna-discussion
>
>

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Sedna-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sedna-discussion

Reply via email to