Is there any other option to extract columns from result than using the op.xpath?
For my code:
var data = op
.fromSearchDocs(cts.collectionQuery('xxx'))
.limit(100)
.select(columns.map(x => op.as(x, op.xpath('doc', '/' + x))))
.result()
.toArray()
data
This select:
.select(columns.map(x => op.as(x, op.xpath('doc', '/' + x))))
Increases the execution time of my code 10 times. The number of columns I want to extract is up to 500 and it is dynamic.
In other hand extracting data with jsearch:
import jsearch from '/MarkLogic/jsearch.mjs';
var res = jsearch
.documents()
.where(cts.collectionQuery('Transactions'))
.slice(0, 10000)
.map({extract: {paths: columns.map(x => '/' + x)}})
.result('iterator');
res
The result is return 4-5 times faster.
I want to use optic because I do some joins before select.