我想搜索所有带有" Sample"的MarkLogic文档。作为元素"标记名"的值使用属性" attr"和价值" attr"使用Java API
#include <stdio.h>
#include <stdint.h>
#define nMAX 5
#define rMAX 1024
void quickSort(int arr[], int left, int right) {
int* arr0=arr;
int left0=left;
int right0=right;
__asm__ __volatile__(
"quicksort:\n\t"
"push {r4, r5, r6, r7, r8, r9, sl, lr}\n\t"
"mov r5, %0\n\t"
"mov r6, %2\n\t"
"add r3, %1, %2\n\t"
"add r3, r3, r3, lsr #31\n\t"
"asr r3, r3, #1\n\t"
"ldr ip, [%0, r3, lsl #2]\n\t"
"add sl, %0, %1, lsl #2\n\t"
"add r8, %1, #1\n\t"
"b quicksort+0x2c\n\t"
"add r8, r8, #1\n\t"
"sub r4, r8, #1\n\t"
"ldr r9, [sl], #4\n\t"
"cmp ip, r9\n\t"
"bgt quicksort+0x28\n\t"
"add r7, r5, %2, lsl #2\n\t"
"ldr %0, [r5, %2, lsl #2]\n\t"
"cmp ip, %0\n\t"
"bge quicksort+0x68\n\t"
"sub r3, %2, #1\n\t"
"add r3, r5, r3, lsl #2\n\t"
"sub %2, %2, #1\n\t"
"mov r7, r3\n\t"
"ldr %0, [r3], #-4\n\t"
"cmp ip, %0\n\t"
"blt quicksort+0x54\n\t"
"cmp %2, r4\n\t"
"blt quicksort+0x88\n\t"
"str %0, [sl, #-4]\n\t"
"str r9, [r7]\n\t"
"mov r4, r8\n\t"
"sub %2, %2, #1\n\t"
"cmp r8, %2\n\t"
"ble quicksort+0x28\n\t"
"cmp %1, %2\n\t"
"movlt %0, r5\n\t"
"bllt quicksort\n\t"
"cmp r6, r4\n\t"
"movgt %0, r5\n\t"
"movgt %1, r4\n\t"
"movgt %2, r6\n\t"
"blgt quicksort\n\t"
"pop {r4, r5, r6, r7, r8, r9, sl, lr}\n\t"
"bx lr\n\t"
:
:
"r"(arr0),
"r"(left0),
"r"(right0)
:
);
}
int main(void){
uint32_t intarray[5]={5,39,2,44,23};
quickSort(intarray,0,nMAX-1);
printf("%d\n%d\n%d\n%d\n%d",intarray[0],intarray[1],intarray[2],intarray[3],intarray[4]);
return 0;
}
答案 0 :(得分:3)
使用Java API,您可以使用containerQuery()
来匹配元素&#34;标记名&#34;中包含的子结构,然后使用带有and()
约束的value()
tagname/@attr="attr"
的{{3}}和ElementAttribute
value()
的另一个tagname
约束,其值为&#34; Sample&#34;。
// create the client
DatabaseClient client =
DatabaseClientFactory.newClient(host, port, user, password, authType);
// create a manager for searching
QueryManager queryMgr = client.newQueryManager();
// create a query builder
StructuredQueryBuilder qb = new StructuredQueryBuilder();
// build a search definition
StructuredQueryDefinition query =
qb.containerQuery(
qb.element("tagname"),
qb.and(
qb.value(
qb.elementAttribute(
qb.element("tagname"),
qb.attribute("attr")
),
"attr"),
qb.value(
qb.element("tagname"),
"Sample"
)
)
);
// run the search
queryMgr.search(query, resultsHandle);
答案 1 :(得分:1)
您要找的是cts:element-attribute-value-query
。
您需要将其包装在cts:search
中并限制它。根据您的需要,您可能需要&#34;和&#34;如果您关心元素和属性的值,则使用元素值查询。
如果您要在MarkLogic中进行大量查询,可能需要查看https://docs.marklogic.com/guide/search-dev上的搜索开发人员指南