This use case looks perfect for what Erik is describing, using 
search:document-query.  Your application can add that directly as part 
of the structured query so there's no need for a constraint.

Sam Mefford
Senior Engineer
MarkLogic Corporation
sam.meff...@marklogic.com
Cell: +1 801 706 9731
www.marklogic.com

This e-mail and any accompanying attachments are confidential. The information 
is intended
solely for the use of the individual to whom it is addressed. Any review, 
disclosure, copying,
distribution, or use of this e-mail communication by others is strictly 
prohibited. If you
are not the intended recipient, please notify us immediately by returning this 
message to
the sender and delete all copies. Thank you for your cooperation.

On 4/1/2015 10:08 AM, Murray, Gregory wrote:
> My use case is a web application for a digital library of books where each 
> XML document is a book (metadata + full text). Normally the user searches the 
> entire database/library of books, but if the user finds a specific book of 
> interest, we want to allow the user to search only within the text of that 
> book and see snippets and page numbers where the term occurs. I actually 
> didn't include the entire search options previously. We also use the 
> following to return search results at the page level rather than the 
> document/book level:
>
>        <!-- only search <page> elements; thus the @path of each search result 
> will indicate a page, not an entire document -->
>        <searchable-expression 
> xmlns:ia="http://digital.library.ptsem.edu/ia";>/ia:doc/ia:text/ia:page</searchable-expression>
>
> For an example, go here and perform a search, let's say for the word "city"
>
> http://commons.ptsem.edu/id/acacianlyricsmis00mund
>
>
> On Apr 1, 2015, at 11:56 AM, Erik Hennum wrote:
>
>> Hi, Danny and Gregory:
>>
>> You can also use a search:document-query in the Search API without using an 
>> additional query.
>>
>>     http://docs.marklogic.com/guide/search-dev/structured-query#id_27172
>>
>> What's the use case for defining a constraint for document URIs?  I wouldn't 
>> expect users to type document uris into a search box or an application to 
>> build facets over document URIs (which by definition have one fragment per 
>> URI).
>>
>>
>> Erik Hennum
>>
>> ________________________________________
>> From: general-boun...@developer.marklogic.com 
>> [general-boun...@developer.marklogic.com] on behalf of Murray, Gregory 
>> [gregory.mur...@ptsem.edu]
>> Sent: Wednesday, April 01, 2015 8:47 AM
>> To: MarkLogic Developer Discussion
>> Subject: Re: [MarkLogic Dev General] search:search constraint for document 
>> URI
>>
>> You can do this with cts:document-query() like so:
>>
>> (: Performs a search for the specified query text within the specified 
>> document. :)
>> declare function m:document-search(
>>   $qtext as xs:string,
>>   $uri as xs:anyURI,
>>   $start as xs:unsignedLong?,
>>   $page-length as xs:unsignedLong?)
>> as element(search:response)
>> {
>>   let $options :=
>>     <options xmlns="http://marklogic.com/appservices/search";>
>>       <!-- limit the search to the specified document -->
>>       <additional-query>{cts:document-query($uri)}</additional-query>
>>     </options>
>>   return search:search($qtext, $options, $start, $page-length)
>> };
>>
>>
>> On Apr 1, 2015, at 11:06 AM, Danny Sinang wrote:
>>
>>> Is it possible to define a search:search constraint to match a document URI 
>>> without having to resort to writing/using a custom constraint ?
>>>
>>>
>>> Regards,
>>> Danny
>>>
>>> _______________________________________________
>>> General mailing list
>>> General@developer.marklogic.com
>>> Manage your subscription at:
>>> http://developer.marklogic.com/mailman/listinfo/general
>> _______________________________________________
>> General mailing list
>> General@developer.marklogic.com
>> Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
>> _______________________________________________
>> General mailing list
>> General@developer.marklogic.com
>> Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to