Hi Radhika,

Glancing through your query I notice some things. You have a nested and-query, 
do you know that cts:and-query can take an sequence of any length? And you have 
an or-query that tests the same element attribute value over and over again, 
with different values. It should be possible to pass one sequence with all 
allowed values to a single cts:element-attribute-value-query, eliminating the 
need for the or-query alltogether.

Not sure why you are searching for specific chapter names though. Is that 
necessary?

Kind regards,
Geert

>


drs. G.P.H. (Geert) Josten
Consultant


Daidalos BV
Hoekeindsehof 1-4
2665 JZ Bleiswijk

T +31 (0)10 850 1200
F +31 (0)10 850 1199

mailto:[email protected]
http://www.daidalos.nl/

KvK 27164984

P Please consider the environment before printing this mail.
De informatie - verzonden in of met dit e-mailbericht - is afkomstig van 
Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit 
bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit 
bericht kunnen geen rechten worden ontleend.

> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> Vedavalli Radhika
> Sent: maandag 17 mei 2010 13:53
> To: [email protected]
> Subject: [MarkLogic Dev General] Performance Tuning -
> cts:search/cts:or Query
>
> We have a requirement for searching the marklogic database
> for documents that satisfies a specific condition - length
> attribute value should be within the specified range and one
> or more chapters from the given chapters should be available.
> The searched information is then filtered based on a fitness
> calculation.
> The execution of the query takes a long time if the dynamic
> or-query becomes long (for bigger inputs, the or-query formed
> will be longer) Are there better ways to optimize this search
> query or atleast the or-query alone?
>
> QUERY:
> for $a in
> cts:search(collection(),
> cts:and-query(
> (
> cts:and-query(
> (cts:element-attribute-range-query(xs:QName("book"),
> xs:QName("length"), ">=", 26),
> cts:element-attribute-range-query(xs:QName("book"),
> xs:QName("length"), "<=", 2620)) ), cts:or-query( (
> cts:element-attribute-value-query(xs:QName("chapter"),
> xs:QName("name"), "chap6"),
> cts:element-attribute-value-query(xs:QName("chapter"),
> xs:QName("name"), "newChap"),
> cts:element-attribute-value-query(xs:QName("chapter"),
> xs:QName("name"), "chap2"),
> cts:element-attribute-value-query(xs:QName("chapter"),
> xs:QName("name"), "chap5"),
> cts:element-attribute-value-query(xs:QName("chapter"),
> xs:QName("name"), "chap3"),
> cts:element-attribute-value-query(xs:QName("chapter"),
> xs:QName("name"), "chap9"),
> cts:element-attribute-value-query(xs:QName("chapter"),
> xs:QName("name"), "chap1"),
> cts:element-attribute-value-query(xs:QName("chapter"),
> xs:QName("name"), "chap4"))
> )
> )
> ), ("score-simple"))
> where $a[(cts:score($a))div(8*($a/book/@chapCnt)) ge 0.1]
> return element hit { attribute score { cts:score($a) }, $a }
> SAMPLE DOCUMENT IN MARKLOGIC:
>  <book author="Author" length="262" id="unique-id" chapCnt="4">
>   <chapter pageStart="5" name="chap1" pageEnd="80" />
>   <chapter pageStart="83" name="chap2" pageEnd="180" />
>   <chapter pageStart="182" name="chap3" pageEnd="401" />
>   <chapter pageStart="405" name="chap4" pageEnd="567" />
>   </book>
>
> Thanks,
> Radhika
>
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to