Sedna performs xquery query and sedna performs xquery

Source: Internet
Author: User
Tags xquery

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.