Следующее описание отвечает на how , его дополнение к этому ответу от @ grtjn.
Эта часть была изменена в запросе:
<search:constraint name="collectionId">
<search:word>
<search:field name="collectionIdField"/>
<search:term-option>case-insensitive</search:term-option>
<search:term-option>unstemmed</search:term-option>
<search:term-option>wildcarded</search:term-option>
<search:term-option>punctuation-insensitive</search:term-option>
</search:word>
</search:constraint>
Я мог бы использовать вышеупомянутое в моем запросе, потому что я создал поле - collectionIdField
типа - path
, с путем как //cd:documentCollections/cd:collection/cd:id
.
Это запрос, используемый для создания поля, это также можно сделать из консоли администратора, но я предпочитаю способ запроса:
xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
(:
get admin configuration
:)
let $config := admin:get-configuration()
(:
Specify the database where you want to create this field
:)
let $dbid := xdmp:database("My-Database")
(:
The field you want to create
:)
let $field-name := "collectionIdField"
(:
Since you are creating a path-field, specify the path.
Multiple field-paths can be specified
:)
let $field-paths := (
admin:database-field-path("//cd:documentCollections/cd:collection/cd:id", xs:double(1.0))
)
(:
Link database-field with field-path
:)
let $fieldspec := admin:database-path-field($field-name, $field-paths)
let $addFieldConfig := admin:database-add-field($config, $dbid, $fieldspec)
(:
Save the new database-add-field configuration to create the field
:)
return admin:save-configuration($addFieldConfig)
Итак, вот мой последний запрос, который фактически работал:
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
search:search("( ( collectionId: ( "54930050DETB6CP71D38" ) ) ) sort:documentCreationDateDES",
<options xmlns="http://marklogic.com/appservices/search">
<term>
<empty apply="all-results"/>
<term-option>unstemmed</term-option>
<term-option>case-insensitive</term-option>
<term-option>punctuation-insensitive</term-option>
<term-option>wildcarded</term-option>
</term>
<additional-query>{cts:directory-query('/dir/subdir01/', "1")}</additional-query>
<transform-results apply="transformed-result" ns="http://searchgui/search" at="/customResultSet.xqy"/>
(:
Constraints or Search Criteria.
- collectionId
- creationDate
:)
<search:constraint name="collectionId">
<search:word>
<search:field name="collectionIdField"/>
<search:term-option>case-insensitive</search:term-option>
<search:term-option>unstemmed</search:term-option>
<search:term-option>wildcarded</search:term-option>
<search:term-option>punctuation-insensitive</search:term-option>
</search:word>
</search:constraint>
<search:constraint name="creationDateRange">
<search:range type="xs:dateTime" facet="false">
<search:bucket ge="0" lt="0" name="documentCreationDate">
Search by Document Creation date / uploaded date
</search:bucket>
<search:element ns="http://any.anyns.com/2013/doc" name="documentCreationDate"/>
<facet-option>limit=10</facet-option>
<facet-option>item-order</facet-option>
<facet-option>descending</facet-option>
</search:range>
</search:constraint>
(:
Sorting options:
- collectionId
- creationDate
:)
<search:operator name="sort">
(: Document Collection Id :)
<search:state name="collectionIdASC">
<search:sort-order direction="ascending" type="xs:string">
<search:path-index ns="http://any.anyns.com/2013/doc">
//cd:documentCollections/cd:collection/cd:id
</search:path-index>
</search:sort-order>
</search:state>
<search:state name="collectionIdDES">
<search:sort-order direction="descending" type="xs:string">
<search:path-index ns="http://any.anyns.com/2013/doc">
//cd:documentCollections/cd:collection/cd:id
</search:path-index>
</search:sort-order>
</search:state>
(: Creation Date :)
<search:state name="documentCreationDateASC">
<search:sort-order direction="ascending" type="xs:dateTime">
<search:element ns="http://any.anyns.com/2013/doc" name="documentCreationDate"/>
</search:sort-order>
</search:state>
<search:state name="documentCreationDateDES">
<search:sort-order direction="descending" type="xs:dateTime">
<search:element ns="http://any.anyns.com/2013/doc" name="documentCreationDate"/>
</search:sort-order>
</search:state>
</search:operator>
</options>, 1, 100);
Field помогает с подстановочными знаками и имеет свои собственные опции-термины, которые будут предоставлены в элементе <word>
, как показано выше.