Hi Blessing, You could create a field index on boostedWord[@isBoosted eq "true"] and use that as constraint. Your current boostWord constraint doesn't take the attribute into account.
Regards, Peter On 15-12-14 17:39, "Blessing N" <[email protected]> wrote: >Hi, > >I have a scenario where the query boosting has to be applied based on >an attribute value in the record. Consider the following records > ><record> ><words> ><word>psychology</word> ><word>Health</word> ><word>Science</word> ></words> ><boostedwords> ><boostedword isBoosted="false">Science</boostedword> ></boostedwords> ></record> > ><record> ><words> ><word>Dream</word> ><word>Health</word> ><word>Science</word> ></words> ><boostedwords> ><boostedword isBoosted="true">Science</boostedword> ></boostedwords> ></record> > >The constraint and query is as follows > >declare variable $CONSTRAINT-OPTIONS := <options >xmlns="http://marklogic.com/appservices/search"> > <constraint name="boostedword"> > <value type="xs:string" facet="false"> > <element ns="" name="boostedword"/> > <weight>50</weight> > </value> > </constraint> > <constraint name="word"> > <value type="xs:string" facet="false"> > <element ns="" name="word"/> > </value> > </constraint> ></options>; > > >let $options := <options xmlns="http://marklogic.com/appservices/search"> > {$CONSTRAINT-OPTIONS/element(), > <transform-results apply="raw"> > </transform-results>} > </options> > let $start:=0 > let $end:=10 > let $query := 'word:Science OR boostedword:Science' > let $q := search:search($query,$options,$start,$end) > return $q > >When this query is executed the score of both the records are high due >to "boostedword" constraint which is expected. >My requirement is that the record score boosting has to apply only for >records having @isBoosted = true. For records with @isBoosted=false >the score should not be boosted. > >Can this be achieved in constructing a query with conditions? > >Thanks, >Blessing. >_______________________________________________ >General mailing list >[email protected] >http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
