I need to create a paginated search for json documents in one collection. Document structure:
{
"Id": "OBJ-0000",
"Title": "sample text",
"Visible": true
}
I created element range indexes on fields Id, Title and Visible, and search options xml configuration:
<?xml version="1.0" encoding="UTF-8"?>
<search:options xmlns:search="http://marklogic.com/appservices/search">
<search:constraint name="id">
<search:range facet="false" type="xs:string">
<search:json-property>Id</search:json-property>
</search:range>
</search:constraint>
<search:constraint name="title">
<search:range facet="false" type="xs:string">
<search:json-property>Title</search:json-property>
</search:range>
</search:constraint>
<search:constraint name="visible">
<search:value type="boolean">
<search:json-property>Visible</search:json-property>
</search:value>
</search:constraint>
<search:operator name="sort">
<search:state name="idAsc">
<search:sort-order direction="ascending">
<search:json-property>Id</search:json-property>
</search:sort-order>
</search:state>
<search:state name="idDesc">
<search:sort-order direction="descending">
<search:json-property>Id</search:json-property>
</search:sort-order>
</search:state>
<search:state name="titleAsc">
<search:sort-order direction="ascending">
<search:json-property>Title</search:json-property>
</search:sort-order>
<search:sort-order direction="descending">
<search:json-property>Id</search:json-property>
</search:sort-order>
</search:state>
<search:state name="titleDesc">
<search:sort-order direction="descending">
<search:json-property>Title</search:json-property>
</search:sort-order>
<search:sort-order direction="descending">
<search:json-property>Id</search:json-property>
</search:sort-order>
</search:state>
<search:state name="isvisibleAsc">
<search:sort-order direction="ascending">
<search:json-property>Visible</search:json-property>
</search:sort-order>
<search:sort-order direction="descending">
<search:json-property>Id</search:json-property>
</search:sort-order>
</search:state>
<search:state name="isvisibleDesc">
<search:sort-order direction="descending">
<search:json-property>Visible</search:json-property>
</search:sort-order>
<search:sort-order direction="descending">
<search:json-property>Id</search:json-property>
</search:sort-order>
</search:state>
</search:operator>
<search:return-results>true</search:return-results>
<search:return-metrics>false</search:return-metrics>
<search:transform-results apply="raw">
</search:transform-results>
<search:debug>false</search:debug>
</search:options>
After, I created POST request with reference to options file:
LATEST/search?format=json&pageLength=20&start=1&options=objectSearch
with structured query:
{
"query": {
"operator-state": {
"operator-name": "sort",
"state-name": "TitleAsc"
},
"and-query": {
"term-query": { "text": "*exam*" }
}
}
}
and it works. But, however, when I make a query with the parameter start=1, in "total" I get more results than it really does, but if I specified start=20 for example, "total" is calculated correctly. This happens only when I use the search parameters with the wildcard (*) in the first place in the search term and term contains more than 3 characters. How I can fix this issue?
trailing wildcardoptions? - grtjn