[MarkLogic Dev General] using lib-search:search-summary
Alan Darnell
alan.darnell at utoronto.ca
Wed Jun 25 17:20:27 PDT 2008
I think I found the answer to my problem with facet counts not
decreasing as new search:values elements are added to a search-
criteria element. In the function "transform-value-facet-query" in
lib-search.xqy, has this code:
let $new-values := (
if ($scope instance of element(search:element-attr)) then
...
else $search-criteria/search:values
[fn:not(
(./search:element/search:local-name)[1] = $scope/
search:local-name and
((./search:element/search:namespace)[1] = $scope/
search:namespace or
(fn:empty(./search:element/search:namespace/
text()) and fn:empty($scope/search:namespace/text())))) ]
,
if ($new-value) then
<values>
{$scope}
<value>{$new-value}</value>
</values>
else ()
)
return
<search:search-criteria>
{$search-criteria/@*}
{$search-criteria/*[fn:local-name(.) ne "values"]}
{$new-values}
</search:search-criteria>
}
By commenting out the logical test following the line $search-criteria/
search:values, the facet counts adjust as new values are added to the
search criteria.
Alan
On Jun 20, 2008, at 12:15 AM, Alan Darnell wrote:
> When I combine a text search with a value search and include an
> option to get facet information, the facet information seems to be
> based only on the text search and not the combination of the text
> and value search. For example, if I run:
>
> import module namespace search="http://www.marklogic.com/ps/lib/lib-search
> " at "modules/lib-search.xqy"
> import module "http://www.marklogic.com/ps/lib/lib-search" at
> "modules/lib-search-custom.xqy"
>
> search:search-summary(
>
> <search:search-criteria fast-pagination="true">
>
> <search:term>
> <search:text>water</search:text>
> </search:term>
>
> <search:values>
> <search:element>
> <search:namespace></search:namespace>
> <search:local-name>kwd</search:local-name>
> </search:element>
> <search:value>NMR</search:value>
> </search:values>
>
>
> <search:facet-defs>
> <search:facet-def do-count="true">
> <search:value-facet>
> <search:element>
> <search:namespace></search:namespace>
> <search:local-name>kwd</search:local-name>
> </search:element>
> <search:top>10</search:top>
> </search:value-facet>
> </search:facet-def>
> </search:facet-defs>
>
> </search:search-criteria>
>
> ,1,1)
>
> I get the following output
>
> <search:search-summary>
> <search:statistics>
> <search:search-results estimate="1400">
> <search:result> ...
> </search:result>
> </search:search-results>
>
> <search:facets>
> <search:facet>
>
> <search:facet-def do-count="true">
> <search:value-facet>
> <search:element>
> <search:namespace/>
> <search:local-name>kwd</search:local-name>
> </search:element>
> <search:top>10</search:top>
> </search:value-facet>
> </search:facet-def>
>
> <search:all count="712714"/>
> <search:item value="Water" count="3390">Water</search:item>
> <search:item value="Adsorption" count="2492">Adsorption</search:item>
> <search:item value="water" count="1785">water</search:item>
> <search:item value="Rat" count="1589">Rat</search:item>
> <search:item value="Temperature" count="1407">Temperature</
> search:item>
> <search:item value="NMR" count="1392">NMR</search:item>
> <search:item value="Heavy metals" count="1331">Heavy metals</
> search:item>
> <search:item value="HPLC" count="1312">HPLC</search:item>
> <search:item value="Modelling" count="1303">Modelling</search:item>
> <search:item value="Kinetics" count="1295">Kinetics</search:item>
>
> </search:facet>
> </search:facets>
>
> </search:search-summary>
>
> ----
>
> The facet search:all at count value is 712714, even though the
> search:search-results at estimate is only 1400. Shouldn't these be the
> same if the two search criteria were in fact being applied in
> calculating the facet counts?
>
> Alan
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
More information about the General
mailing list