Ashish,
Here's the facet definition section in the lib-search-custom file that
we use and that works for us. Of course, we have range indexes
defined for each of the element or attributes we want to facet on.
Alan
<facets>
<default-do-count>true</default-do-count>
<search:value-facet id="kwd-facet">
<search:element>
<search:local-name>kwd</search:local-name>
</search:element>
<search:top>10</search:top>
</search:value-facet>
<search:value-facet id="journal-facet">
<search:element>
<search:local-name>journal-title</search:local-name>
</search:element>
<search:top>10</search:top>
</search:value-facet>
<search:value-facet id="article-type-facet">
<search:element-attr>
<search:local-name>article</search:local-name>
<search:attr-local-name>article-type</search:attr-
local-name>
</search:element-attr>
<search:top>10</search:top>
</search:value-facet>
</facets>
On Jul 11, 2008, at 5:23 AM, Ashish Kumar wrote:
Hi,
I am trying to work out facet based search. Basically I have added
<facet-def in search criteria and facets in lib-search-custom.xqy.
I do get search:search-summary along with
parse/search/estimate/summary/facet time and document-uri in the
results
But I dont see any results for facets based search. Basically I have 5
articles in the database and all have PublisherName tag.
So I suppose it should give results for "PublisherName" with the
total no
articles as 5.
What I am missing here.
Pointers to the following will be appreciated. Here goes the code.
1. Search Criteria in cq
import module namespace search="http://www.marklogic.com/ps/lib/lib-search
"
at "lib-search.xqy"
import module "http://www.marklogic.com/ps/lib/lib-search" at
"lib-search-custom.xqy"
search:search-summary(
<search:search-criteria>
<search:term><search:text>cell</search:text></search:term>
<facet-def do-count="true">
<facet-def-id>PublisherName-facet-id</facet-def-id>
</facet-def>
</search:search-criteria>
, 1, 5)
2. Config element in lib-search-custorm.xqy
define variable $CONFIG as element(cfg:config) {
(: Configuration file -- Put whatever you want here, or nothing
at all.
:)
<config xmlns="http://www.marklogic.com/ps/lib/lib-search/config">
<search>
<namespaces>
<namespace
prefix="sp">http://www.foo.com</namespace>
</namespaces>
<base-criteria>
<search:directories depth="infinity">
<search:directory>lib-searchWebDev/</search:directory>
</search:directories>
</base-criteria>
<sort-fields>
<sort-field
id="ChapterTitle"
type="xs:string"
direction="ascending">
Publisher//Chapter/ChapterInfo/ChapterTitle
</sort-field>
<sort-field
id="CopyrightYear"
type="xs:integer"
direction="ascending">
Publisher//Chapter//ChapterCopyright/CopyrightYear
</sort-field>
</sort-fields>
<max-summarize-matches>5</max-summarize-matches>
<truncate-word-count>7</truncate-word-count>
</search>
<facets>
<default-do-count>true</default-do-count>
<search:value-facet id="PublisherName-facet-id">
<search:element id="PublisherName">
<search:namespace></search:namespace>
<search:local-name>PublisherName</search:local-name>
</search:element>
</search:value-facet>
</facets>
</config>
}
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general