marklogic-samplestack icon indicating copy to clipboard operation
marklogic-samplestack copied to clipboard

Samplestack extensions not compatible with MarkLogic 9 JavaScript

Open grechaw opened this issue 9 years ago • 5 comments

Hi Charles— I’m playing around with the Optic EA3 stuff (instructions at https://ea.marklogic.com/features/data-integration/optic-api/) and I’m trying to use the UI. The port is open, no errors in the log, but the server is throwing this error:

2016-09-27 11:42:34.839 Info: Status 500: JS-JAVASCRIPT: var sourceDoc = fn.doc(uri).next().value; -- Error running JavaScript request: TypeError: fn.doc(...).next is not a function

The UI is giving me this exception:

{"data":{"status":400,"message":"com.marklogic.client.FailedRequestException: Local message: search failed: Bad Request. Server Message: JS-JAVASCRIPT: var sourceDoc = fn.doc(uri).next().value; -- Error running JavaScript request: TypeError: fn.doc(...).next is not a function"},"status":400,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null,null],"url":"/v1/search","data":{"search":{"qtext":["","sort:active"],"start":1,"timezone":"America/New_York"}},"timeout":60000,"headers":{"Accept":"application/json, text/plain, /","Content-Type":"application/json;charset=utf-8"}},"statusText":"Bad Request”}

$scope.runSearch/<@http://localhost:8090/app/states/explore.js:300:21 processQueue@http://localhost:8090/deps/angular/angular.js:13170:27 scheduleProcessQueue/<@http://localhost:8090/deps/angular/angular.js:13186:27 $RootScopeProvider/this.$get

grechaw avatar Oct 11 '16 16:10 grechaw

This would appear to be a compatibility issue that arose when we changed the iterable api in ML. I believe the solution would be to fix the JS transform in the server.

laurelnaiad avatar Oct 11 '16 17:10 laurelnaiad

https://github.com/marklogic/marklogic-samplestack/blob/master/database/transforms/search-response.sjs#L98

var answersSource = sourceDoc.xpath(answerNodePath).next().value;

to something like

const pos = sourceDoc.xpath(answerNodePath);
const answersSource = pos.toArray ? pos.toArray()[0] : pos.next().value;

would probably do it, I think, but not tested.

laurelnaiad avatar Oct 11 '16 18:10 laurelnaiad

fn.head(…) will work in MarkLogic ≥8.

jmakeig avatar Oct 11 '16 18:10 jmakeig

Verified that this bug prevents the application from working, and also prevents loading of RDF data. The database is other wise loaded correctly.

grechaw avatar Oct 12 '16 16:10 grechaw

After making these changes in search-response.sjs following tests are giving assertions error at the time of deploying samplestack.

DatabaseQnADocumentSearchIT. guestSearchSeesOnlyResolvedQuestions
DatabaseQnADocumentSearchIT. testAcceptedSearch
DatabaseQnADocumentSearchIT. testActivitySearch
DatabaseQnADocumentSearchIT. testResponseExtracts
QnADocumentControllerIT. testAnonymousAccessToAccepted
TagControllerIT. testRelatedTags
TagControllerIT. testSortFrequency

ashutosha avatar Jun 01 '17 04:06 ashutosha