Yes, you will, it just affects word query. Sent from my iPhone
On Mar 17, 2012, at 10:12 AM, "Jakob Fix" <[email protected]> wrote: > Thanks Colleen, once I knew the magic phrase that is "word query > specification" I also found an illustrative blog post by David > Cassell: http://blog.davidcassel.net/2011/10/word-query-specification/ > > I hope that I'll still be able to create facets on other parts of the > document. > > thanks! > Jakob. > > > > On Sat, Mar 17, 2012 at 16:04, Colleen Whitney > <[email protected]> wrote: >> Jakob, if you want to restrict all unconstrained terms to a particular part >> of your content, you can configure a Word Query specification on you >> database. It's just like configuring a field, but controls how all word >> queries are evaluated. >> >> Sent from my iPhone >> >> On Mar 17, 2012, at 7:32 AM, "Jakob Fix" <[email protected]> wrote: >> >>> I'd like to know whether the (working) solution below is the way to go >>> or whether there are better ways. >>> >>> Here it goes: I'd like to restrain a simple word search to a number of >>> elements, like so: >>> >>> cts:search(/*, >>> cts:and-query(( >>> cts:element-word-query( >>> (xs:QName("abstract"), >>> xs:QName("title"), >>> xs:QName("subTitle") >>> ), >>> "query" >>> ) >>> )) >>> ) >>> >>> but I'd like to also use the search:search API in order to profit from >>> the snippeting, paging and reporting features it provides. >>> >>> I've looked at the <additional-query> option and indeed it works when >>> including the above cts:and-query, but I'm not sure whether that is >>> the optimal way of restraining search:search to a number of elements, >>> in particular the fact that I have to repeat the search term ($term) >>> seems kind of suboptimal: >>> >>> let $term := "cambodia" >>> >>> let $additional-query := cts:and-query(( >>> cts:element-word-query( >>> (fn:QName("http://purl.org/dc/terms/", "abstract"), >>> fn:QName("http://purl.org/dc/terms/", "title"), >>> fn:QName("http://purl.org/dc/terms/", "subtitle") >>> ), >>> $term >>> ) >>> )) >>> >>> let $options := >>> <options xmlns="http://marklogic.com/appservices/search"> >>> <additional-query>{$additional-query}</additional-query> >>> <return-facets>false</return-facets> >>> <debug>true</debug> >>> </options> >>> >>> return search:search($term, $options) >>> >>> >>> I had looked also at using <element-query> constraints to constrain >>> the search to these elements only, but the <constraint> options seem >>> to provide a facility to further constrain the search via their name, >>> but I'm looking to only ever search in the three elements. >>> >>> <constraint name="title"> >>> <element-query ns="http://purl.org/dc/terms/" name="title"/> >>> </constraint> >>> <constraint name="abstract"> >>> <element-query ns="http://purl.org/dc/terms/" name="abstract"/> >>> </constraint> >>> <constraint name="subtitle"> >>> <element-query ns="http://purl.org/dc/terms/" name="subtitle"/> >>> </constraint> >>> >>> Defining these constraints would allow me to do >>> search:search("title:cambodia subtitle:cambodia abstract:cambodia", >>> $options) but my overall goal is to only search a number of predefined >>> elements for any search. And repeating the constraints and the terms >>> in the search seems clumsy. >>> >>> I didn't have more luck with the <word> constraint option, for the >>> same reason as the <element-query> option. >>> >>> <constraint name="title"> >>> <word> >>> <element ns="http://purl.org/dc/terms/" name="title"/> >>> </word> >>> </constraint> >>> <constraint name="abstract"> >>> <word> >>> <element ns="http://purl.org/dc/terms/" name="abstract"/> >>> </word> >>> </constraint> >>> >>> So is the <additional-query> approach the way to go? >>> >>> Thanks, >>> Jakob. >>> _______________________________________________ >>> General mailing list >>> [email protected] >>> http://developer.marklogic.com/mailman/listinfo/general >> _______________________________________________ >> General mailing list >> [email protected] >> http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
