Hi ,
My xml document contains information about books (Id, author, Pubdate, Title 
and Abstract). I would like to search the document with facet on Publish date.  
 I have used range constraint with Buckets of year range. When user search for 
the author (say “Surjit”) the expected result should be one Facet i.e. 1980s 
and count should 1.
 
Since there are multiple books (node) in single xml, facet is not working 
properly. 
 
 
Please find the xml document and XQuery as follows. 
<?xmlversion="1.0"encoding="utf-8"?>
<books>
      <bookId='1'>
            <author>Surjit Singh Barnala</author>
            <pubDate>1983</pubDate>
            <Title>My other two daughters’</Title>
            <Abstract>
                  An eminent politician writes a simple but engrossing novel 
that has nothing to do with politics 
                  but about two women whom he loved as daughters</Abstract>
      </book>
<bookId='2'>
            <author>SIVA PRASAD DANTU</author>
            <pubDate>1995 </pubDate>
            <Title>TWO WORDS THAT BRING TRUE HAPPINESS</Title>
            <Abstract>TWO WORDS THAT BRING THE REAL HAPPYNESS TO YOU You know 
these words that bring the true happiness to you.But at the same time you... 
</Abstract>
      </book>
      <bookId='3'>
            <author>Charles Dickens </author>
            <pubDate>2000 </pubDate>
            <Title>Tale of Two Cities </Title>
            <Abstract>Tale of Two Cities by Charles Dickens The theme of Tale 
of Two Cities is that ill-treatment will eventually be repaid by 
ill-treatment——not...</Abstract>
      </book>
</books>
 
xQuery
 
xquery version "1.0-ml";
import module namespace search = "http://marklogic.com/appservices/search"; at 
"/MarkLogic/appservices/search/search.xqy";
let $options := <options xmlns="http://marklogic.com/appservices/search";>
<return-results>true</return-results>
<return-facets>true</return-facets>
 <constraint name="facet-on-PubDate">
 <range type="xs:gYear" >
 <facet-option>limit=10</facet-option>
<element ns="" name="pubDate"/>
<bucket ge="1980" lt="1991" name="1980s">1980s</bucket>
<bucket ge="1991" lt="2001"  name="1990s">1990s</bucket>
<bucket ge="2001" lt="2011"  name="2000s">2000s</bucket>
 </range>
</constraint>
</options>
let $ds:= search:search("Surjit", $options)
return $ds
 
Search Result 
 
- <<search: facet name="facet-on-PubDate">
 <<search: facet-value name="1980s"count="1">1980s</search: facet-value> 
 <<search: facet-value name="1990s"count="1">1990s</search: facet-value> 
 <<search: facet-value name="2000s"count="1">2000s</search: facet-value> 
 </search: facet>
 
 
 The query text “Surjit” exists only in Book (id 1) (i.e Pub Date is 1980), 
since the xml document contains multiple books we are getting the all facets 
with count as 1.  But expected result is 
 
-   <search: facet name="facet-on-PubDate">
 <<search: facet-value name="1980s"count="1">1980s</search: facet-value>  
 </search: facet>
 
Above query is working fine if I have separate xml for  each book.
 
Regards,
Mano


      The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. 
http://in.yahoo.com/
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to