1
votes

With the below query I would like to modify the options so that I am only retrieving the values. The query returns the path, the relevance as well as values. I just need the values so I can edit it for reporting purposes. Can I get some insight on how to accomplish this task? I am also using the Javascript API within Marklogic 8.

results = jsearch.documentSelect(cts.search($error_details), 
                     {namespaces: {//emf:namespace is declared here},
                      extract: {paths: ['//emf:properties/emf:property[@key = "filename"]/.',
                               '//emf:properties/emf:property[@key = "idnumber"]/.',
                               '//emf:properties/emf:property[@key = "error description"]/.',
                               '//emf:properties/emf:property[@key = "error code"]/.']}
                     }).toString();

The query

cts.andQuery([
cts.elementRangeQuery(fn.QName('uri','creation-time'), ">=", $startDate),
cts.elementRangeQuery(fn.QName('uri','creation-time'), "<", $endDate),
cts.elementValueQuery(fn.QName('uri','component-name'), "InvalidFiles" ),
cts.elementValueQuery(fn.QName('uri','category'), "error")
])
2

2 Answers

1
votes

It sounds like the jsearch.documentSelect() wrapper might not be necessary in this case.

The cts.search() function returns the documents as a ValueIterator in MarkLogic 8.

One easy way to process the documents is to chain the toArray() functions -- as in cts.search().toArray() -- and then chain the standard array map() or reduce() functions to convert the documents into the report.

Footnote: cts.search() returns a Sequence in MarkLogic 9, but sequences also have a toArray() function.

Hoping that helps,

0
votes

There are multiple search options which allow you to customize your search response. For example, you can disable to return aggregates with this option:

<options xmlns="http://marklogic.com/appservices/search">
  <return-aggregates>false</return-aggregates>
</options>

The query returns the path, the relevance as well as values.

If you mean score, confidence and fitness by "relevance", i dont think there is an option for that.