您好,我是使用 MarkLogic 9 结合 NodeJS 进行查询的新手,并尝试使用 MarkLogic 9 示例中提到的 QBE(按示例查询)(https://docs.marklogic.com/guide/search-dev /qbe ) 当我使用带有以下语句的 xquery 时:
xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";
let $items := fn:collection()/scope/item
for $i in $items
let $sscc := $i/*:transaction/*:sscc/text()
let $type:= $i/*:transaction/*:type/text()
let $actorId := $i/*:transaction/*:actorId/text()
let $device := $i/*:transaction/*:device/text()
let $ordernummer := $i/*:order/*:orderNumber/text()
where $ordernummer = 3788888
return <td>{$sscc}</td>
返回 46 个正确结果。当我尝试使用 QBE 执行此操作时:
exports.postQuery = function(req, res) {
var queryInput = req.body.message
console.info('Start postQuery!!!')
console.info(queryInput)
db.documents.query(
//qb.where(qb.byExample(
// queryInput
qb.byExample({
$query: {
orderNumber: {$word : '3788888'},
$filtered: true
},
$format: 'json'
}))
它返回 10 个结果而不是 46 个。它与我使用哪个订单号无关,所有可能性都显示 10 条记录。你能告诉我我做错了什么吗?
MarkLogic 中的源 xml 文件采用以下格式:
<scope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<item>
<transaction>
<type>CI</type>
<sscc>00000379471900000025</sscc>
<location>4260210630688</location>
<device>VISTALINK.004</device>
<date>2017-04-25</date>
<time>02:15:33</time>
<gmtOffset>+02:00</gmtOffset>
<actorId>155081</actorId>
</transaction>
<order>
<orderNumber>3794719</orderNumber>
</order>
<load>
<rti>
<ean>8714548186004</ean>
<grai>8003087145481860040019877322</grai>
<column>2</column>
<size>
<width>1900</width>
<height>95</height>
<depth>0</depth>
</size>
<position>
<x>2062,48707520218</x>
<y>2015,24337520512</y>
<z>0</z>
</position>
</rti>
<rti>
<ean>8714548106002</ean>
<grai>8003087145481060020016434653</grai>
<column>0</column>
<size>
<width>1900</width>
<height>95</height>
<depth>0</depth>
</size>
<position/>
</rti>
<rti>
<ean>8714548186004</ean>
<grai>8003087145481860040012803719</grai>
<column>2</column>
<size>
<width>1900</width>
<height>95</height>
<depth>0</depth>
</size>
<position>
<x>2064,20629390666</x>
<y>2124,57539157396</y>
<z>0</z>
</position>
</rti>
<rti>...</rti>
<rti>...</rti>
<rti>...</rti>
<rti>...</rti>
<rti>...</rti>
</load>
</item>
</scope>
曼尼谢谢
埃里克