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: <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of Florent Georges <li...@fgeorges.org<mailto:li...@fgeorges.org>> Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Date: Tuesday, October 24, 2017 at 8:12 AM To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> 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 H2O Consulting http://h2o.consulting/ On 23 October 2017 at 17:44, Geert Joste wrote: I think I would use a field for this.. Cheers, Geert From: <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of Florent Georges <li...@fgeorges.org<mailto:li...@fgeorges.org>> Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Date: Monday, October 23, 2017 at 4:42 PM To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> 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 General@developer.marklogic.com<mailto:General@developer.marklogic.com> Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general