Hi Dave,

 

I think your FLWOR statements need to have a predicate around them.
Something like:

 

if ($dir eq 'ascending') then
            (for $i in cts:search(collection(tokenize($region, ',')),
$query)
            order by $i/PATENT/PATNUM ascending empty least
            return $i)[1 to 10]
        else
            (for $i in cts:search(collection(tokenize($region, ',')),
$query)
            order by $i/PATENT/PATNUM descending empty least
            return $i)[1 to 10]

 

-Danny



 

From: [email protected]
[mailto:[email protected]] On Behalf Of Dave
Feldmeier
Sent: Friday, April 03, 2009 3:49 PM
To: [email protected]
Subject: [MarkLogic Dev General] Order by is optimized when descending
butnot ascending?

 

Something odd is happening when I try to sort using a range element -
when "descending" is used, it adds a constraint to the search, but it
doesn't add a constraint to the search when "ascending" is used. I don't
understand why - see the details below.

                   -Dave

David Feldmeier
Twin Dolphin Software, Inc.
303 Twin Dolphin Drive, Suite 600
Redwood City, CA 94065 


Here's the snippet of code:

        if ($dir eq 'ascending') then
            for $i in cts:search(collection(tokenize($region, ',')),
$query)
            order by $i/PATENT/PATNUM ascending empty least
            return $i
        else
            for $i in cts:search(collection(tokenize($region, ',')),
$query)
            order by $i/PATENT/PATNUM descending empty least
            return $i

PATNUM is a string range element with values such as US20010000951A1.

I am running 4.0.3 on Redhat Enterprise Linux 4 on a 64-bit Intel
platform.

Here's what I get when using "descending":

2009-04-03 15:24:15.690 Info: gazelle2: /lib/patent.xqy line 329:
Analyzing path for search: collection("US")
2009-04-03 15:24:15.690 Info: gazelle2: /lib/patent.xqy line 329: Step 1
is searchable: collection("US")
2009-04-03 15:24:15.690 Info: gazelle2: /lib/patent.xqy line 329: Path
is fully searchable.
2009-04-03 15:24:15.690 Info: gazelle2: /lib/patent.xqy line 329:
Gathering constraints.
2009-04-03 15:24:15.690 Info: gazelle2: /lib/patent.xqy line 329: Search
query contributed 1 constraint: cts:element-query(expanded-QName("",
"ASSC_AEN"), cts:word-query("example", ("lang=en"), 1), ())
2009-04-03 15:24:15.690 Info: gazelle2: /lib/patent.xqy line 329: Order
by clause contributed 1 range ordering constraint for $i: order by
$i/child::PATENT/child::PATNUM descending empty greatest
2009-04-03 15:24:15.690 Info: gazelle2: /lib/patent.xqy line 329:
Executing search.
2009-04-03 15:24:15.731 Info: gazelle2: /lib/patent.xqy line 329:
Selected 4281 fragments to filter.


But here's what I get using "ascending":

2009-04-03 15:24:12.900 Info: gazelle2: /lib/patent.xqy line 325:
Analyzing path for search: collection("US")
2009-04-03 15:24:12.900 Info: gazelle2: /lib/patent.xqy line 325: Step 1
is searchable: collection("US")
2009-04-03 15:24:12.900 Info: gazelle2: /lib/patent.xqy line 325: Path
is fully searchable.
2009-04-03 15:24:12.900 Info: gazelle2: /lib/patent.xqy line 325:
Gathering constraints.
2009-04-03 15:24:12.900 Info: gazelle2: /lib/patent.xqy line 325: Search
query contributed 1 constraint: cts:element-query(expanded-QName("",
"ASSC_AEN"), cts:word-query("example", ("lang=en"), 1), ())
2009-04-03 15:24:12.900 Info: gazelle2: /lib/patent.xqy line 325:
Executing search.
2009-04-03 15:24:12.925 Info: gazelle2: /lib/patent.xqy line 325:
Selected 4281 fragments to filter.






_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to