In that case, have a look at cts:parse. Much faster than search:parse 
(allegedly), and much more flexible. I have used it for various purposes, even 
ones that don’t result in a cts:query.. ;-)

Cheers

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of Florent Georges <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Tuesday, October 24, 2017 at 11:10 AM
To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Set of elements to search for 
search:search()

Well, the whole point is that I need to add a "search grammar" to the search 
text field the user sends (supporting AND, OR, double quotes, etc.)  So if I 
have a structured query, I would simply use CTS.

The point is precisely to parse such a string.  And also to get the snippets. 
Hence the try to switch to the Search API.

But if it is not possible to configure several elements for the un-constraint 
terms, I guess the solution is rather to implement and parse my own grammar, 
and generating the snippets using CTS... :-(

Regards,

--
Florent Georges
H2O Consulting
http://h2o.consulting/


On 24 October 2017 at 09:06, Geert Josten wrote:
Hi Florent,

Have you considered using rest api’s capability to take a structured query, 
rather than relying on search options? That way you can send in complex custom 
adhoc queries, including those you are after.

Yes, you can give different weights in a field, but as you might guess, that is 
fixed too..

Cheers,
Geert

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of Florent Georges <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Tuesday, October 24, 2017 at 8:12 AM
To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Set of elements to search for 
search:search()

Hi Geert,

Thank you.  Unfortunately, that would require to create fields for any possible 
combination of elements.  The list of elements is computed algorithmically, and 
that would not be possible with fields.

Furthermore, I think that would not allow to give different weights to 
different elements either, would it?  Basically, I need to be able to say 
"element foo weight 10, element bar weight 5, etc."

So I guess my question is, is not there any way to ask search:search() to 
generate cts:and-query((cts:element-word-query(), cts:element-word-query())) 
instead of a simple cts:element-word-query(), for a simple term search string?

Regards,

--
Florent Georges
http://fgeorges.org/
http://h2o.consulting/ - New website!


On 23 October 2017 at 17:44, Geert Joste wrote:
I think I would use a field for this..

Cheers,
Geert

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of Florent Georges <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Monday, October 23, 2017 at 4:42 PM
To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] Set of elements to search for search:search()

Hi,

I am using the Search API, AKA search:search().  I need to restrict the set of 
elements to use for a search string with no specific constraint (e.g. "this AND 
that" as opposed to "this:that").

As a simplification, let's say I need to restrict the search to two elements, 
namely "foo" and "bar", in no namespace, with different weights.  I would have 
used the following, but "default" seems to accept only one "word":

search:search(
   'this AND that',
   <options xmlns="http://marklogic.com/appservices/search";>
      <term>
         <default>
            <word>
               <element name="foo" ns=""/>
               <weight>10.0</weight>
            </word>
            <word>
               <element name="bar" ns=""/>
               <weight>5.0</weight>
            </word>
         </default>
      </term>
   </options>)

MarkLogic does not complain on this one, but only takes the first one into 
account (well, at least the results returned are as if it was).

I feel I am missing something obvious here.  How is it possible to restrict a 
full text search to a set of element names using search:search()?

Regards;

--
Florent Georges
http://fgeorges.org/
http://h2o.consulting/ - New website!



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








_______________________________________________
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