Reputation: 1
The following MarkLogic search is doing a case-sensitive search? How to perform a case-insensitive search using the following code snippet?
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());
Upvotes: 0
Views: 350
Reputation: 7335
Andy:
KeyValueQueryDefinition is intended for the simplest cases. Your requirements have graduated to a more sophisticated interface.
You can use StructuredQueryBuilder to pass in options for your element values query:
http://docs.marklogic.com/javadoc/client/com/marklogic/client/query/StructuredQueryBuilder.html
Something along the lines of the following code (untested) should work:
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);
Hoping that helps
Upvotes: 2