title: MarkLogic Query By Example returns incorrect result
body: <p>Hello i am new to Querying with MarkLogic 9 in combination with NodeJS and try to use the QBE (Query By Example) as it is mentioned in the example of MarkLogic 9 ( <a href="https://docs.marklogic.com/guide/search-dev/qbe" rel="nofollow noreferrer">https://docs.marklogic.com/guide/search-dev/qbe</a> ) When i use xquery with the following statement:</p>
  
  <pre><code>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 &lt;td&gt;{$sscc}&lt;/td&gt;
  </code></pre>
  
  <p>Which returns 46 correctresult. When i try to do this with QBE with:</p>
  
  <pre><code>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'
  }))
  </code></pre>
  
  <p>it returns 10 results instead of 46. It does not mater which order number i use all possibilities shows 10 records. Can you please tell me what i am doing wrong.</p>
  
  <p>The source xml files within MarkLogic are in this format:</p>
  
  <pre><code>&lt;scope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;item&gt;
          &lt;transaction&gt;
              &lt;type&gt;CI&lt;/type&gt;
              &lt;sscc&gt;00000379471900000025&lt;/sscc&gt;
              &lt;location&gt;4260210630688&lt;/location&gt;
              &lt;device&gt;VISTALINK.004&lt;/device&gt;
              &lt;date&gt;2017-04-25&lt;/date&gt;
              &lt;time&gt;02:15:33&lt;/time&gt;
              &lt;gmtOffset&gt;+02:00&lt;/gmtOffset&gt;
              &lt;actorId&gt;155081&lt;/actorId&gt;
          &lt;/transaction&gt;
          &lt;order&gt;
              &lt;orderNumber&gt;3794719&lt;/orderNumber&gt;
          &lt;/order&gt;
          &lt;load&gt;
              &lt;rti&gt;
                  &lt;ean&gt;8714548186004&lt;/ean&gt;
                  &lt;grai&gt;8003087145481860040019877322&lt;/grai&gt;
                  &lt;column&gt;2&lt;/column&gt;
                  &lt;size&gt;
                      &lt;width&gt;1900&lt;/width&gt;
                      &lt;height&gt;95&lt;/height&gt;
                      &lt;depth&gt;0&lt;/depth&gt;
                  &lt;/size&gt;
                  &lt;position&gt;
                      &lt;x&gt;2062,48707520218&lt;/x&gt;
                      &lt;y&gt;2015,24337520512&lt;/y&gt;
                      &lt;z&gt;0&lt;/z&gt;
                  &lt;/position&gt;
              &lt;/rti&gt;
              &lt;rti&gt;
                  &lt;ean&gt;8714548106002&lt;/ean&gt;
                  &lt;grai&gt;8003087145481060020016434653&lt;/grai&gt;
                  &lt;column&gt;0&lt;/column&gt;
                  &lt;size&gt;
                      &lt;width&gt;1900&lt;/width&gt;
                      &lt;height&gt;95&lt;/height&gt;
                      &lt;depth&gt;0&lt;/depth&gt;
                  &lt;/size&gt;
                  &lt;position/&gt;
              &lt;/rti&gt;
              &lt;rti&gt;
                  &lt;ean&gt;8714548186004&lt;/ean&gt;
                  &lt;grai&gt;8003087145481860040012803719&lt;/grai&gt;
                  &lt;column&gt;2&lt;/column&gt;
                  &lt;size&gt;
                      &lt;width&gt;1900&lt;/width&gt;
                      &lt;height&gt;95&lt;/height&gt;
                      &lt;depth&gt;0&lt;/depth&gt;
                  &lt;/size&gt;
                  &lt;position&gt;
                      &lt;x&gt;2064,20629390666&lt;/x&gt;
                      &lt;y&gt;2124,57539157396&lt;/y&gt;
                      &lt;z&gt;0&lt;/z&gt;
                  &lt;/position&gt;
              &lt;/rti&gt;
              &lt;rti&gt;...&lt;/rti&gt;
              &lt;rti&gt;...&lt;/rti&gt;
              &lt;rti&gt;...&lt;/rti&gt;
              &lt;rti&gt;...&lt;/rti&gt;
              &lt;rti&gt;...&lt;/rti&gt;
          &lt;/load&gt;
      &lt;/item&gt;
  &lt;/scope&gt;
  </code></pre>
  
  <p>Manny thanks</p>
  
  <p>Erik</p>