Hi, Martin:

The score() function declares sorting by relevance by default, so you shouldn't 
have to supply any argument to score.

By default documents.query() returns the documents.

If you want to return only a report with the document scores and not the 
documents, you can use the withOptions clause, as in:

    .withOptions({categories:'none'})

The score() function should be passing the score method.  As a workaround, you 
can set the score method using the search options key with the withOptions 
clause, as in:

    .withOptions({search:['score-random']})


Hoping that helps,


Erik Hennum

________________________________
From: [email protected] 
[[email protected]] on behalf of Martin Vollmix 
[[email protected]]
Sent: Sunday, June 07, 2015 8:17 AM
To: 'MarkLogic Developer Discussion'
Subject: [MarkLogic Dev General] sort by relevance with querybuilder in node.js

Hi,

I am trying to create a query using relevance with querybuilder in node.js

My first attempt looks like this:

    db.documents.query(
        q.where(
            q.collection("housedata"),
                q.parsedFrom(req.body.SearchString))
                .orderBy(q.sort(q.score("random"), "descending")
        )
    )

But this results in an error:
{ [Error: query documents: response with invalid 400 status]
  message: 'query documents: response with invalid 400 status',
  statusCode: 400,
  body:
  { errorResponse:
  { statusCode: 400,
        status: 'Bad Request',
        messageCode: 'REST-INVALIDPARAM',
        message: 'REST-INVALIDPARAM: (err:FOER0000) Invalid parameter: Invalid 
combined search\nRESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: 
Operation
results in invalid Options: XDMP-VALIDATEUNEXPECTED: (err:XQDY0027) validate 
strict { $opt } -- Invalid node: Found text{"random..."} but expected ()
at /search:search/search:options/search:sort-order/search:score/text() using 
schema 
"search.xsd"text{"random..."}()/search:search/search:options/search:sort-order/search:score/text()"search.xsd"'
 } } }

If I use score() with no argument it is working, bur no ranking info is 
returned.

Can anybody help me out?

Thanks in advance !

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

Reply via email to