前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >sedna进行xquery查询

sedna进行xquery查询

作者头像
血狼debugeeker
发布2018-09-20 14:53:14
4470
发布2018-09-20 14:53:14
举报
文章被收录于专栏:debugeeker的专栏

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1344591

有一个文件book.xml:

代码语言:javascript
复制
<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数据库:

代码语言:javascript
复制
[root@localhost xuzhina]#se_cdb books
Creating a database (this can take a few minutes)...
The database 'books' has been created successfully

启动它:

代码语言:javascript
复制
[root@localhost 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:

代码语言:javascript
复制
[root@localhost xuzhina]#se_term -query "CREATE COLLECTION 'novel'" books
UPDATE is executed successfully

加载进去:

代码语言:javascript
复制
[root@localhost xuzhina]#se_term -query "LOAD 'book.xml' 'book' 'novel'" books
Bulk load succeeded

查询整个文件:

代码语言:javascript
复制
[root@localhost 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:

代码语言:javascript
复制
[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:

代码语言:javascript
复制
[root@localhost 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开始的):

代码语言:javascript
复制
[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:

代码语言:javascript
复制
[root@localhost 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>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2015年07月06日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档