今天看啥
热点:

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数据库:

[[email protected] xuzhina]#se_cdb books
Creating a database (this can take a few minutes)...
The database 'books' has been created successfully

启动它:

[[email protected] xuzhina]#se_sm books
Starting database recovery or hot-backup restoration...
Database is in consistent state. Starting...
SM has been started in the background mode

创建一个collection叫novel:

[[email protected] xuzhina]#se_term -query "CREATE COLLECTION 'novel'" books
UPDATE is executed successfully

加载进去:

[[email protected] xuzhina]#se_term -query "LOAD 'book.xml' 'book' 'novel'" books
Bulk load succeeded

查询整个文件:

[[email protected] xuzhina]#se_term -query "for $p in collection('novel')/books return $p" book
s
<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:

[[email protected] 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:

[[email protected] xuzhina]#se_term -query "for $p in collection('novel')/books/book[name='The
Call 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开始的):

[[email protected] 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:

[[email protected] xuzhina]#se_term -query "for $p in collection('novel')/books/book[contains(n
ame, '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>


版权声明:本文为博主原创文章,未经博主允许不得转载。

www.bkjia.comtruehttp://www.bkjia.com/sjkqy/1027250.htmlTechArticlesedna进行xquery查询,sedna进行xquery 有一个文件book.xml: booksbooknameThe Call Of Wild/nameauthorJack London/authorprice32.5$/pricedate2015-7-6/date/bookbooknameWutheri...

相关文章

帮客评论

视觉看点