I came up with the solution below.

Maybe someone else here has a better approach.

                *let **$path* :=
"/contrib-group/contrib[@contrib-type='author']/author-name-string"

                *let* *$collation* := "http://marklogic.com/collation/en/S2";
                *let* *$options* := ("type=string", "collation=" ||
*$collation*)
                *let* *$ref* := *cts:path-reference*(*$path*, *$options*)
                *let* *$value-matches* := *let **$matches* :=
*cts:value-match* (*$ref*, *$author*)
                                      *return*
                                            *if* (*$matches*) *then*
                                                *$matches*
                                            *else*
                                                ""
                *return*
                        *cts:path-range-query* (*$path*, "=",
*$value-matches*, "collation=" || *$collation*)

On Tue, Apr 21, 2015 at 8:39 PM, Danny Sinang <[email protected]> wrote:

> We've got article authors stored like this :
>
>                 <contrib-group>
>                     <contrib contrib-type="author" >
>                         <author-name-string>John Baker, Ph.D.</
> author-name-string>
>
>                     </contrib>
>                     <contrib contrib-type="author" >
>                         <author-name-string>Sarah Reynolds, Ph.D.</
> author-name-string>
>
>                     </contrib>
>                 </contrib-group>
>
>
> And we'd like the following search strings match the first contrib node
> above :
>
> 1. john*
>
> 2. john Bak*
>
> 3. *Baker*
>
> And we'd like this search string match both both contrib nodes above :
>
> *Ph.D.
>
>
> My questions are :
>
> 1. What database index settings do I need to set (e.g. trailing wildcard,
> etc) ?
>
> 2. What kind of indexes do I need to make ?
>
> 3. What search API options do I need to create ?
>
> 4. If I need to create a custom constraint that returns a cts query, what
> cts query option should I use ?
>
>
> I've tried creating custom constraints that return either
> cts:element-value-query or cts:element-word-query but I seem to be getting
> false positives. For example, if I search for john ba*, I get articles with
> authors named John (some other surname), or Brian Bass.
>
>
> Regards,
>
> Danny
>
>
>
>
>
>
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to