Hi Charles,

Actually, I think this *is* exactly what I'm looking for. I had never noticed 
the <default> element before, but it sounds like I can use this approach to 
force all search keywords not already under a constraint ("prefixless" as you 
put it) to apply only to a specific element -- which is exactly what I need to 
do. I'm working in a web application where the user can choose whether to 
search everything (full text), only titles, or only author names. So when I'm 
setting up the <options> element for search:search(), I can just check the 
scope specified by the user, and if the user wants a title-only search, include 
the <default> like you indicated below.

This is much simpler than what I was doing. In fact, since I already have a 
title constraint defined (as in my original message below), it looks like I can 
just do this:

<term>
<default ref="title"/>
</term>

Many thanks!
Greg


On Dec 5, 2013, at 6:49 PM, Charles Greer wrote:

> Hi Greg,
> 
> If you want all prefixless searches to be scoped to a particular 
> element, use the <term> configuration
> 
> <term>
> <default>
> <word>
> <element ns="" name="title"/>
> </word>
> </default>
> </term>
> 
> I don't see a way to do exactly what you're looking for however.
> 
> Charles
> 
> 
> On 12/04/2013 11:27 AM, Murray, Gregory wrote:
>> I'm using the Search API, where it's easy enough to set up a word constraint 
>> for a given element and then use the key:value syntax to search only the 
>> values of that element, like so:
>> 
>>     <constraint name="title">
>>       <word>
>>         <element ns="http://example.com/ns"; name="title"/>
>>       </word>
>>     </constraint>
>> 
>> Then you can search for title:whatever to find titles containing the word 
>> "whatever". This works great, but it's cumbersome for multi-word searches. 
>> For example, if I want titles containing both "sound" and "fury", I have to 
>> search for this:
>> 
>>     title:sound title:fury
>> 
>> It gets worse with situations like this:
>> 
>>     (title:encyclopedia OR title:dictionary) AND (title:music OR 
>> title:musicology)
>> 
>> Before I dig into trying to customize the search grammar or some such -- is 
>> there an easier way to perform a word search while applying the *entire* 
>> search expression only to a given element?
>> 
>> Thanks,
>> Greg
>> 
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
> 
> -- 
> Charles Greer
> Senior Engineer
> MarkLogic Corporation
> [email protected]
> Phone: +1 707 408 3277
> www.marklogic.com
> 
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

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

Reply via email to