Hi Rahul, Having such a searchable expression would require filtering. Total estimates are based on unfiltered results, so they typically include so called false positives.
To get more accurate counts you’d best add a path index on p/@search or img/@search, and include/exclude that with a range query. Cheers, Geert From: <[email protected]<mailto:[email protected]>> on behalf of "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Reply-To: MarkLogic Developer Discussion <[email protected]<mailto:[email protected]>> Date: Monday, December 19, 2016 at 12:23 PM To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Subject: [MarkLogic Dev General] Issue with MarkLogic REST returning varying total number of results on each search Hi We are having MarkLogic REST Search as below on the following document. Content: <root> <data> <p search=”true”>paragraph</p> <p search=”true”>paragraph</p> </data> <images> <img search=”true”>image</img> <img search=”true”>image</img> </ images > </root> We need to search for all the elements that have “search” as attribute. We need to exclude ‘img’ tags in the xml. So we are using ‘searchable-element’ to restrict the ‘img’ tags. Options: search.xml <optionsxmlns="http://marklogic.com/appservices/search"> <termapply="term"> <emptyapply="all-results"/> <term-option>case-insensitive</term-option> </term> <searchable-expression>//*[@ssearch and local-name(.) ne "img"]</searchable-expression> </options> Issue: We see the total number of results varying when we change the ‘start’ parameter value http://host:port/v1/search?q=&collection=Pages&options=search&format=xml&start=1&pageLength=10 <search:response xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:search="http://marklogic.com/appservices/search" snippet-format="raw" total="6390" start="1" page-length="10"> http://host:port/v1/search?q=&collection=Pages&options=search&format=xml&start=11&pageLength=10 <search:response xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:search="http://marklogic.com/appservices/search" snippet-format="raw" total="6395" start="11" page-length="10"> http://host:port/v1/search?q=&collection=Pages&options=search&format=xml&start=21&pageLength=10 <search:response xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:search="http://marklogic.com/appservices/search" snippet-format="raw" total="6401" start="21" page-length="10"> However, on using unfiltered search we don’t see the issue with “total” number of results, but the img tag is being returned in the search. It should be excluded in the search results. <search-option>unfiltered</search-option> We need img tags to be eliminated with correct number of “total” results for each search. Thanks Rahul This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.
_______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
