You could always rewrite the query after it comes back from search:parse, but
it might be more efficient to write a custom parser function. You would specify
the function in your search options:
<search:term apply="myfunc"
ns="my-library-module-ns"
at="my-library-module.xqy">
<search:empty apply="no-results" />
</search:term>
That function would have to implement the and-query vs near-query logic. It
might look something like:
import module namespace sdev="http://marklogic.com/appservices/search/searchdev"
at "/MarkLogic/appservices/search/custom-parse.xqy";
declare function m:search-term(
$ps as map:map,
$term as element()?)
as schema-element(cts:query)
{
document {
(: consider a typeswitch instead of if-then-else :)
if (not($term instance of element(cts:and-query))) then $term
else cts:near-query(
cts:and-query-queries($term), 3, ('ordered')) }/*
,
sdev:advance($ps)
};
-- Mike
On 12 Sep 2012, at 18:43 , Alan Darnell wrote:
> I have this section in my search options node:
>
> <grammar>
>
> <implicit>
>
> <cts:near-query strength="20"
> xmlns:cts="http://marklogic.com/cts"/>
>
> </implicit>
>
> </grammar>
>
> This turns the default search from a cts;and-query to cts:near-query, but I
> want to tighten up the search.
>
> What I really want is to have the cts:near-query implement options so that
> the words in the query must be 3 words apart and must appear in the same
> order as entered.
>
> Is there a way to do this with the search api?
>
> Alan
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general