[MarkLogic Dev General] Search for element values containing spaces fails when enabling "word positions" and "element word positions" on database

Danny Sinang d.sinang at gmail.com
Wed Mar 18 03:06:00 PDT 2015


After I set to true the databases settings below (to resolve some other
issue), our search:search API calls started failing when searching for an
element with spaces or slashes

1. word positions
2. element word positions


Here's a sample of a query that used to, but no longer does return results
(after the DB settings change) - because "Infectious Disease" has a space
in it.

'(entry:(key:1 AND value:(qBankDimensions:(name:"Sub-Specialty" AND
dimensionFacts:(name:"Infectious Disease"))))'

The same problem exists when searching for "Nephrology/Urology".

But if you search for "Cardiology" (or any value without spaces or
slashes), we get search results.

Any idea on why this is happening ?

We are using ML 7.0-3 and ML 7.0-4.3 on Windows.

Below is the query I run from QConsole :

Regards,
Danny

=======================================================

xquery version "1.0-ml";

declare namespace didl="urn:mpeg:mpeg21:2002:02-DIDL-NS";
declare namespace mms="http://www.mycomp.org/elements/";


import module namespace search = "http://marklogic.com/appservices/search"
    at "/MarkLogic/appservices/search/search.xqy";


declare option xdmp:mapping "true";

declare variable $OPTIONS :=

 <options xmlns="http://marklogic.com/appservices/search">
  <search-option>filtered</search-option>  <!-- [SUPPORT !11762] -->
  <debug>false</debug>
  <term>
   <empty apply="all-results"/>
   <term-option>wildcarded</term-option>
   <term-option>case-insensitive</term-option>
   <term-option>punctuation-sensitive</term-option>
    <term-option>diacritic-sensitive</term-option>
  </term>
  <grammar>
    <starter strength="30" apply="grouping" delimiter=")">(</starter>
    <starter strength="40" apply="prefix"
element="cts:not-query">-</starter>
    <joiner strength="10" apply="infix" element="cts:or-query"
tokenize="word">OR</joiner>
    <joiner strength="20" apply="infix" element="cts:and-query"
tokenize="word">AND</joiner>
    <joiner strength="20" apply="element-joiner" ns="
http://www.mycomp.org/custom-field-query" at="/lib/custom-fields.xqy"
element="cts:element-query" tokenize="word">CHILD</joiner>
    <joiner strength="50" apply="constraint" compare="LT"
tokenize="word">LT</joiner>
    <joiner strength="50" apply="constraint" compare="LE"
tokenize="word">LE</joiner>
    <joiner strength="50" apply="constraint" compare="GT"
tokenize="word">GT</joiner>
    <joiner strength="50" apply="constraint" compare="GE"
tokenize="word">GE</joiner>
    <joiner strength="50" apply="constraint" compare="NE"
tokenize="word">NE</joiner>
    <quotation>"</quotation>
    <joiner strength="50" apply="constraint">:</joiner>
  </grammar>

  <searchable-expression xmlns:app="">/questionAsset</searchable-expression>

  <constraint name="qbankId">
    <value>
      <element ns="" name="qBankId"/>
    </value>
  </constraint>
  <constraint name="key">
    <value>
      <element ns="" name="key"/>
    </value>
  </constraint>
  <constraint name="qId">
    <value>
      <element ns="" name="qId"/>
    </value>
  </constraint>
  <constraint name="productId">
    <value>
      <element ns="" name="productId"/>
    </value>
  </constraint>
  <constraint name="qAuthoringState">
    <value>
      <element ns="" name="qAuthoringState"/>
    </value>
  </constraint>
  <constraint name="qBankMembershipState">
    <value>
      <element ns="" name="qBankMembershipState"/>
    </value>
  </constraint>
  <constraint name="qApName">
    <value>
      <element ns="" name="qApName"/>
    </value>
  </constraint>
  <constraint name="accreditationTypeState">
    <value>
      <element ns="" name="accreditationTypeState"/>
    </value>
  </constraint>
  <constraint name="questionSetName">
    <value>
      <element ns="" name="questionSetName"/>
    </value>
  </constraint>
<!-- boolean queries: -->
  <constraint name="qComments">
<custom facet="false">
  <parse apply="qComments" ns="http://www.mycomp.org/custom-field-query"
at="/lib/custom-fields.xqy"/>
</custom>
  </constraint>
  <constraint name="qSupplementGroup">
<custom facet="false">
  <parse apply="qSupplementGroup" ns="
http://www.mycomp.org/custom-field-query" at="/lib/custom-fields.xqy"/>
</custom>
  </constraint>
  <constraint name="qQuestionOfTheWeek">
<custom facet="false">
  <parse apply="qQuestionOfTheWeek" ns="
http://www.mycomp.org/custom-field-query" at="/lib/custom-fields.xqy"/>
</custom>
  </constraint>
  <constraint name="qFITB">
<custom facet="false">
  <parse apply="qFITB" ns="http://www.nejm.org/custom-field-query"
at="/lib/custom-fields.xqy"/>
</custom>
  </constraint>
<!-- range queries: -->
  <constraint name="qApDifferentiation">
    <range type="xs:double">
      <element ns="" name="qApDifferentiation"/>
    </range>
  </constraint>
  <constraint name="qApDiscrimination">
    <range type="xs:double">
      <element ns="" name="qApDiscrimination"/>
    </range>
  </constraint>
  <constraint name="qApRelevance">
    <range type="xs:double">
      <element ns="" name="qApRelevance"/>
    </range>
  </constraint>
  <constraint name="qCreatedDate">
    <range type="xs:dateTime">
      <element ns="" name="qCreatedDate"/>
    </range>
  </constraint>
  <constraint name="qLastModifiedDate">
    <range type="xs:dateTime">
      <element ns="" name="qLastModifiedDate"/>
    </range>
  </constraint>

  <constraint name="qAudiencePoolGroup">
    <element-query ns="" name="qAudiencePoolGroup"/>
  </constraint>

  <constraint name="qBankGroup">
    <element-query ns="" name="qBankGroup"/>
  </constraint>

  <constraint name="qBankDimensions">
    <element-query ns="" name="qBankDimensions"/>
  </constraint>

  <constraint name="dimensionFacts">
    <element-query ns="" name="dimensionFacts"/>
  </constraint>

  <constraint name="childDimension">
    <element-query ns="" name="childDimension"/>
  </constraint>

  <constraint name="name">
    <value>
      <element ns="" name="name"/>
    </value>
  </constraint>

  <constraint name="dimension">
<custom facet="false">
  <parse apply="dimension" ns="http://www.mycomp.org/custom-field-query"
at="/lib/custom-fields.xqy"/>
</custom>
  </constraint>
  <constraint name="entry">
    <element-query ns="" name="entry"/>
  </constraint>

  <constraint name="value">
    <element-query ns="" name="value"/>
  </constraint>

  <return-query xmlns="http://marklogic.com/appservices/search
">true</return-query>
  <return-facets xmlns="http://marklogic.com/appservices/search
">true</return-facets>
  <return-metrics xmlns="http://marklogic.com/appservices/search
">false</return-metrics>
</options> ;


let $search-query        :=
'
(entry:(key:5 AND value:(qBankDimensions:(name:"Sub-Specialty" AND
dimensionFacts:(name:"Infectious Disease")))
)
 '

let $directory           := "/questions/"
let $additional-query    :=
                            <additional-query xmlns="
http://marklogic.com/appservices/search">
                            {
                                cts:directory-query($directory, "infinity")
                            }
                            </additional-query>
let $options             :=
                    <options xmlns="http://marklogic.com/appservices/search
">
                    {$OPTIONS/*}
                    {$additional-query}
                        </options>
let $tempResults := search:search($search-query, $options, 1, 1000)
return
        <response>
            {$tempResults}
        </response>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20150318/e2dd8a93/attachment-0001.html 


More information about the General mailing list