Thanks much Danny, that worked. To drill down into one of the facets, will I need to re-run the original search with an additional element-value constraint? Thanks.
On Tue, Aug 4, 2009 at 9:26 PM, Danny Sokolsky <[email protected] > wrote: > Hi Surajit, > > I think the problem here is that the genre element in your sample document > is not in the namespace "http://www.sb.com/namespaces/sb", but is in no > namespace. The xmlns:b declaration in the book element just binds the > prefix to the namespace, it does not make all of the child elements in that > namespace. If you re-insert the following document, you will get facet > results: > > <book xmlns="http://www.sb.com/namespaces/sb"> > <title>The Life of David Gale</title> > <genre>fiction</genre> > <desc>....</desc> > <review>...</review> > </book> > > So the facet was empty because it did not match any of the documents. > > -Danny > > From: [email protected] [mailto: > [email protected]] On Behalf Of Surajit > Bhattacharjee > Sent: Tuesday, August 04, 2009 4:58 PM > To: [email protected] > Subject: [MarkLogic Dev General] faceted navigation using search:search not > working > > I have 10 documents loaded in Mark Logic, each containing information about > a single book. Below is a sample document. > > <?xml version="1.0" encoding="UTF-8"?> > <book xmlns:sb="http://www.sb.com/namespaces/sb"> > <title>The Life of David Gale</title> > <genre>fiction</genre> > <desc>....</desc> > <review>...</review> > </book> > > I have defined string range index on the "genre" element so that I can > facet on genres when user search for books. I am trying to use the > search:search API in 4.1 but can't get this to work. The search works fine, > but no facets get returned. Here is the code from CQ: > > xquery version "1.0-ml"; > import module namespace search = "http://marklogic.com/appservices/search" > at "/MarkLogic/appservices/search/search.xqy"; > search:search("life", > <options xmlns="http://marklogic.com/appservices/search"> > <constraint name="facet-on-genre"> > <range type="xs:string" facet="true"> > <facet-option>limit=10</facet-option> > <element ns="http://www.sb.com/namespaces/sb" name="genre"/> > </range> > </constraint> > </options>) > > Here is the response I get: > > <search:response total="4" start="1" page-length="10" xmlns:search=" > http://marklogic.com/appservices/search"> > <search:result index="1" uri="a.xml" path="doc("a.xml")" > score="80" confidence="0.430638" fitness="0.67929"> > <search:snippet>...</search:snippet> > </search:result> > <search:result index="2" uri="c.xml" path="doc("c.xml")" > score="80" confidence="0.430638" fitness="0.67929"> > <search:snippet>...</search:snippet> > </search:result> > ...2 more search-result elements... > <search:facet name="facet-on-genre"/> > <search:qtext>refrigerator</search:qtext> > <search:metrics> > <search:query-resolution-time>PT0.016S</search:query-resolution-time> > <search:facet-resolution-time>PT0S</search:facet-resolution-time> > > <search:snippet-resolution-time>PT0.016S</search:snippet-resolution-time> > <search:total-time>PT0.032S</search:total-time> > </search:metrics> > </search:response> > > Can someone please help? > Thanks. > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general >
_______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
