3
votes

I have unique requirement to autosuggest on element names and json property names.

XML Example:

<?xml  version="1.0" encoding="UTF-8"?>
<ns2:Envelope ns1:version="1.2" xmlns:ns2="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3 = "http://test.com/2016/doc">
<ns2:Body>
    <ns3:docID>D253456</ns3:docID>
<ns2:Body>

I was able to get suggest on values via java-client-api with options. Range index in background.

String[] results = queryMgr.suggest(sd);

or I can use something via xquery

declare namespace ns3 = "http://test.com/2016/doc";
cts:element-value-match(xs:QName("ns3:docID"),fn:concat("D25","*"))[1 to 10];

But unable to find way for element name suggest like doc* return docId

Can we get autosuggest on the element/json property names like docID in marklogic? if yes, how can do it via java-client-api.

1

1 Answers

4
votes

As you know, markLogic "suggest" is based on word lexicon or value lexicons (range indexes). I'm not aware of a word lexicon or value lexicon that can capture the element or property names. I think your best bet here is to modify your documents to contain an element or property containing the value you want to index / suggest.

Something like this:

<?xml  version="1.0" encoding="UTF-8"?>
<ns2:Envelope ns1:version="1.2" xmlns:ns2="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3 = "http://test.com/2016/doc">
<ns2:Body>
    <ns3:docID>D253456</ns3:docID>
    <ns3:elementName>docId</ns3:elementName>
    <ns3:elementName>elementName</ns3:elementName>
<ns2:Body>