[MarkLogic Dev General] RE: Unable to sort results through
Ashish Kumar
a.kumar at mpstechnologies.com
Tue Jul 1 02:31:43 PDT 2008
Hi,
I got the search with sort (lib-search) working. (Sharing the code) I was
missing the namespace declaration in the sort tag
Here is the code.
1.
import module namespace search="http://www.marklogic.com/ps/lib/lib-search"
at "lib-search.xqy"
import module namespace search1="http://www.marklogic.com/ps/lib/lib-search"
at "lib-search-custom.xqy"
let $results :=search:search-results(
<search:search-criteria>
<search:term><search:text>cell</search:text>
<search:element><search:local-name>Abstract</search:local-name></search:elem
ent>
</search:term>
<search1:sort>
<search1:sort-field-id>ChapterTitle</search1:sort-field-id>
<search1:direction>ascending</search1:direction>
</search1:sort>
</search:search-criteria>
, 1, 5)
return
<MarkLogicResults>
{
for $result in $results
return
<result>
{$result/Chapter/ChapterInfo/ChapterTitle}
{$result//ChapterDOI}
{$result//Author}
{$result//Chapter//ChapterCopyright/CopyrightYear}
{$result//Abstract}
</result>
}</MarkLogicResults>
2. Here is the setting which we need to do in lib-search-custom.xqy in
$CONFIG element
<sort-fields>
<sort-field
id="ChapterTitle"
type="xs:string"
direction="ascending">
Chapter/ChapterInfo/ChapterTitle
</sort-field>
</sort-fields>
-----Original Message-----
From: Ashish Kumar [mailto:a.kumar at mpstechnologies.com]
Sent: Monday, June 30, 2008 11:19 AM
To: 'general at developer.marklogic.com'
Cc: 'Frank.Sanders at marklogic.com'
Subject: RE: Unable to sort results through
Thanx for the quick response Frank,
I am sorry I forgot to mention that my search results are not sorted in the
last mail.
Still after doing the suggested change; results are not sorted.
Infact after doing the following changes
<search:directory>testWebDAVServer/</search:directory>
To
<search:directory>/testWebDAVServer/</search:directory>
I don't get any results.
Regards,
/Ashish
-----Original Message-----
From: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] On Behalf Of
general-request at developer.marklogic.com
Sent: Saturday, June 28, 2008 12:30 AM
To: general at developer.marklogic.com
Subject: General Digest, Vol 48, Issue 14
Send General mailing list submissions to
general at developer.marklogic.com
To subscribe or unsubscribe via the World Wide Web, visit
http://xqzone.com/mailman/listinfo/general
or, via email, send a message with subject or body 'help' to
general-request at developer.marklogic.com
You can reach the person managing the list at
general-owner at developer.marklogic.com
When replying, please edit your Subject line so it is more specific
than "Re: Contents of General digest..."
Today's Topics:
1. Unable to sort results through lib-search (Ashish Kumar)
2. RE: Unable to sort results through lib-search (Frank Sanders)
----------------------------------------------------------------------
Message: 1
Date: Fri, 27 Jun 2008 17:08:43 +0530
From: "Ashish Kumar" <a.kumar at mpstechnologies.com>
Subject: [MarkLogic Dev General] Unable to sort results through
lib-search
To: <general at developer.marklogic.com>
Message-ID: <007301c8d84a$5c1b4650$9f011dac at Mpstechnologies.com>
Content-Type: text/plain; charset="us-ascii"
Hi,
Pointers to the following problem will be highly appreciated.
I am unable to sort search results using lib search.
Also I see the api is broken for highlighting the results in lib-search. Any
idea when it would be available.
Here is the code which I am trying to sort the results. What I am missing
here?
1. In lib-search-custorm.xqy I have set the $CONFIG AS
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>
<base-criteria>
<search:directories depth="1">
<search:directory>testWebDAVServer/</search:directory>
</search:directories>
</base-criteria>
<sort-fields>
<sort-field id="pName" type="xs:string"
direction="ascending"
>/Publisher/PublisherInfo/PublisherName</sort-field>
</sort-fields>
<max-summarize-matches>5</max-summarize-matches>
<truncate-word-count>7</truncate-word-count>
</search>
</config>
}
/Publisher/PublisherInfo/PublisherName is the path from root.
2. Now when I fire my query for sort it does not work
import module namespace search="http://www.marklogic.com/ps/lib/lib-search"
at "lib-search.xqy"
import module namespace search1="http://www.marklogic.com/ps/lib/lib-search"
at "lib-search-custom.xqy"
search:search-results(
<search:search-criteria>
<search:term><search:text>humana</search:text></search:term>
<search:element><search:local-name>Body
</search:local-name></search:element>
<sort><sort-field type="xs:string"> pName
</sort-field><sort-field-id>ChapterTitle</sort-field-id></sort>
</search:search-criteria>
, 1, 5)
Thanx in Advance,
/Ashish
------------------------------
Message: 2
Date: Fri, 27 Jun 2008 07:54:34 -0700
From: "Frank Sanders" <Frank.Sanders at marklogic.com>
Subject: RE: [MarkLogic Dev General] Unable to sort results through
lib-search
To: "General Mark Logic Developer Discussion"
<general at developer.marklogic.com>
Message-ID: <6C2CD7495641AE43A064B5450D73C318F780CC at EX1.marklogic.com>
Content-Type: text/plain; charset="us-ascii"
Not sure of what results you're getting, but from the code you've posted it
looks like you need to change your search-directory element from:
<search:directory>testWebDAVServer/</search:directory>
To
<search:directory>/testWebDAVServer/</search:directory>
-fs
-----Original Message-----
From: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] On Behalf Of Ashish Kumar
Sent: Friday, June 27, 2008 7:39 AM
To: general at developer.marklogic.com
Subject: [MarkLogic Dev General] Unable to sort results through lib-search
Hi,
Pointers to the following problem will be highly appreciated.
I am unable to sort search results using lib search.
Also I see the api is broken for highlighting the results in lib-search. Any
idea when it would be available.
Here is the code which I am trying to sort the results. What I am missing
here?
1. In lib-search-custorm.xqy I have set the $CONFIG AS
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>
<base-criteria>
<search:directories depth="1">
<search:directory>testWebDAVServer/</search:directory>
</search:directories>
</base-criteria>
<sort-fields>
<sort-field id="pName" type="xs:string"
direction="ascending"
>/Publisher/PublisherInfo/PublisherName</sort-field>
</sort-fields>
<max-summarize-matches>5</max-summarize-matches>
<truncate-word-count>7</truncate-word-count>
</search>
</config>
}
/Publisher/PublisherInfo/PublisherName is the path from root.
2. Now when I fire my query for sort it does not work
import module namespace search="http://www.marklogic.com/ps/lib/lib-search"
at "lib-search.xqy"
import module namespace search1="http://www.marklogic.com/ps/lib/lib-search"
at "lib-search-custom.xqy"
search:search-results(
<search:search-criteria>
<search:term><search:text>humana</search:text></search:term>
<search:element><search:local-name>Body
</search:local-name></search:element>
<sort><sort-field type="xs:string"> pName
</sort-field><sort-field-id>ChapterTitle</sort-field-id></sort>
</search:search-criteria>
, 1, 5)
Thanx in Advance,
/Ashish
_______________________________________________
General mailing list
General at developer.marklogic.com
http://xqzone.com/mailman/listinfo/general
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4245 bytes
Desc: not available
Url :
http://xqzone.marklogic.com/pipermail/general/attachments/20080627/a36d9b52/
smime-0001.bin
------------------------------
_______________________________________________
General mailing list
General at developer.marklogic.com
http://xqzone.com/mailman/listinfo/general
End of General Digest, Vol 48, Issue 14
***************************************
More information about the General
mailing list