sedna進行xquery查詢,sedna進行xquery

來源:互聯網
上載者:User

sedna進行xquery查詢,sedna進行xquery

有一個檔案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>


建立books資料庫:

[root@localhost xuzhina]#se_cdb booksCreating a database (this can take a few minutes)...The database 'books' has been created successfully

啟動它:

[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

建立一個collection叫novel:

[root@localhost xuzhina]#se_term -query "CREATE COLLECTION 'novel'" booksUPDATE is executed successfully

載入進去:

[root@localhost xuzhina]#se_term -query "LOAD 'book.xml' 'book' 'novel'" booksBulk load succeeded

查詢整個檔案:

[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>


查詢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>

查詢某個書名的book:

[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>

查詢第2本書(記住它的索引是從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>

查詢某個書的書名包括某個詞語,比如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>


著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

相關文章

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.