以下MarkLogic搜索正在进行区分大小写的搜索?如何使用以下代码段执行不区分大小写的搜索?
String optionsName = "PRODUCT_BY_TITLE";
String options ="<search:options xmlns:search='http://marklogic.com/appservices/search'>"+ "</search:options>";
QueryOptionsManager qoManager =
client.newServerConfigManager().newQueryOptionsManager();
// create a handle to send the query options
StringHandle writeHandle = new StringHandle(options);
// write the query options to the database
qoManager.writeOptions(optionsName, writeHandle);
QueryManager queryMgr = client.newQueryManager();
KeyValueQueryDefinition kvqdef = queryMgr.newKeyValueDefinition(optionsName);
kvqdef.put(queryMgr.newElementLocator(new QName(ConstantsUtil.BIBLIOGRAPHIC_MSG_NAMESPACE_PREFIX+":"+elementName)), elementValue);
JacksonHandle handle = new JacksonHandle();
queryMgr.search(kvqdef, handle);
logger.info("response-->"+handle.toString());
答案 0 :(得分:2)
安迪:
KeyValueQueryDefinition适用于最简单的情况。您的要求已逐渐变为更复杂的界面。
您可以使用StructuredQueryBuilder传递元素值查询的选项:
http://docs.marklogic.com/javadoc/client/com/marklogic/client/query/StructuredQueryBuilder.html
以下代码(未经测试)的某些内容应该有效:
StructuredQueryBuilder qb = new StructuredQueryBuilder(optionsName);
StructuredQueryDefinition queryDef = qb.value(
qb.element(new QName(
ConstantsUtil.BIBLIOGRAPHIC_MSG_NAMESPACE_PREFIX+":"+elementName)),
FragmentScope.DOCUMENTS,
new String[]{"case-insensitive"},
1,
elementValue);
JacksonHandle handle = new JacksonHandle();
queryMgr.search(queryDef, handle);
希望有帮助