Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Samplestack extensions not compatible with MarkLogic 9 JavaScript #703

Open
grechaw opened this issue Oct 11, 2016 · 5 comments
Open

Samplestack extensions not compatible with MarkLogic 9 JavaScript #703

grechaw opened this issue Oct 11, 2016 · 5 comments

Comments

@grechaw
Copy link
Contributor

grechaw commented Oct 11, 2016

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

@laurelnaiad
Copy link
Contributor

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
Copy link
Contributor

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.

@jmakeig
Copy link
Contributor

jmakeig commented Oct 11, 2016

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

@grechaw
Copy link
Contributor Author

grechaw commented Oct 12, 2016

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

Luiz-N added a commit to Luiz-N/marklogic-samplestack that referenced this issue Nov 2, 2016
@ashutosha
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants