Sedna performs xquery query and sedna performs xquery
There is a file book. xml:
<books><book><name>The Call Of Wild</name><author>Jack London</author><price>32.5$</price><date>2015-7-6</date></book><book><name>Wuthering Heights</name><author>Emily Bronte</author><price>40$</price><date>2015-7-5</date></book></books>
Create a books database:
[root@localhost xuzhina]#se_cdb booksCreating a database (this can take a few minutes)...The database 'books' has been created successfully
Start it:
[root@localhost xuzhina]#se_sm booksStarting database recovery or hot-backup restoration...Database is in consistent state. Starting...SM has been started in the background mode
Create a collection named novel:
[root@localhost xuzhina]#se_term -query "CREATE COLLECTION 'novel'" booksUPDATE is executed successfully
Load in:
[root@localhost xuzhina]#se_term -query "LOAD 'book.xml' 'book' 'novel'" booksBulk load succeeded
Query the entire file:
[root@localhost xuzhina]#se_term -query "for $p in collection('novel')/books return $p" books<books> <book> <name>The Call Of Wild</name> <author>Jack London</author> <price>32.5$</price> <date>2015-7-6</date> </book> <book> <name>Wuthering Heights</name> <author>Emily Bronte</author> <price>40$</price> <date>2015-7-5</date> </book></books>
Query book:
[root@localhost xuzhina]#se_term -query "for $p in collection('novel')/books/book return $p" books<book> <name>The Call Of Wild</name> <author>Jack London</author> <price>32.5$</price> <date>2015-7-6</date></book><book> <name>Wuthering Heights</name> <author>Emily Bronte</author> <price>40$</price> <date>2015-7-5</date></book>
Query the book of a specific title:
[root@localhost xuzhina]#se_term -query "for $p in collection('novel')/books/book[name='TheCall Of Wild'] return $p" books<book> <name>The Call Of Wild</name> <author>Jack London</author> <price>32.5$</price> <date>2015-7-6</date></book>
Query 2nd books (remember that its index starts from 1 ):
[root@localhost xuzhina]#se_term -query "for $p in collection('novel')/books/book[2] return$p" books<book> <name>Wuthering Heights</name> <author>Emily Bronte</author> <price>40$</price> <date>2015-7-5</date></book>
Query the title of a book, including a word, such as Call:
[root@localhost xuzhina]#se_term -query "for $p in collection('novel')/books/book[contains(name, 'Call')] return $p" books<book> <name>The Call Of Wild</name> <author>Jack London</author> <price>32.5$</price> <date>2015-7-6</date></book>
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.