Thanks Charles.  We ended up modifying the word query settings and dropping the 
“anywhere" field.  That gives us the behaviour we want.

Alan


On Jun 21, 2017, at 5:58 PM, Charles Greer 
<[email protected]<mailto:[email protected]>> wrote:

Hi Alan

I think your field contraint is fine-- the default grammar simply expects a 
different syntax.

I could be mistaken, but I think either of the following expressions will give 
you ANDed queries:

ANY:"x AND y"

ANY:x ANY:y

See if that gives you what you need.  There may be a way beyond this to use the 
grammar configuration
to move you toward the syntax you've used, but it's not occurring to me off the 
top of my head.


Charles


Charles Greer
Lead Engineer
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Cell:  +1 707 318 0442
@grechaw
www.marklogic.com<http://www.marklogic.com/>

________________________________
From: 
[email protected]<mailto:[email protected]>
 
[[email protected]<mailto:[email protected]>]
 on behalf of Alan Darnell 
[[email protected]<mailto:[email protected]>]
Sent: Tuesday, June 20, 2017 2:54 PM
To: General Developer Discussion
Subject: [MarkLogic Dev General] field constraint in search API

Having a little trouble setting up a field constraint in the Search API and 
can’t find an answer in the documentation.

We’ve created a field called “anywhere” composed of a number of elements that 
appear in our standard XML document.

We’ve also created a constraint called ANY defined as:

<constraint name=“ANY”>
<word>
<field name=“anywhere” />
</word>
</constraint>

We are sending the string ANY:(x y) to the search API.  We are looking for this 
to turn into two AND’d word queries but what we get is a phrase search on “x y”.

Here’s the output from the search API:

<search:report id="SEARCH-FLWOR">
(cts:search(/book, cts:field-word-query("anywhere", "x y", ("lang=en"), 1), 
("score-logtfidf",cts:score-order("descending")), 1))[1 to 20]
</search:report>

We were hoping instead for something like this.

<search:report id="SEARCH-FLWOR">
(cts:search(/book, cts:field-word-query(“anywhere"), 
cts:and-query((cts:word-query("x", 
("case-insensitive","diacritic-insensitive","punctuation-insensitive","wildcarded","lang=en"),
 1), cts:word-query("y", 
("case-insensitive","diacritic-insensitive","punctuation-insensitive","wildcarded","lang=en"),
 1)), ()), ()), ("score-logtfidf",cts:score-order("descending")), 1))[1 to 20]
</search:report>

Is this kind of search possible with fields?  If so, how should the constraint 
be defined?

Thanks in advance,

Alan
_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general

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

Reply via email to