2017-04-15 7 views
1

属性 "attr"と値 "attr"の要素 "tagname"の値として "Sample"を持つすべてのMarkLogic文書を検索したいJava APIタグの特定の値を持つすべてのmarklogic文書を検索したい

<tagname attr="attr">Sample</tagname> 
+0

「タグ」とは何ですか?それは要素ですか?質問が完全な文脈になるように、あなたのコンテンツのサンプルサンプルを挙げてください。 –

+0

@DavidEnnis私が話しているタグが追加されました – CrazyNerd

答えて

3

の検索開発者ガイドをチェックアウトする場合がありますMarkLogicに照会をたくさんやってしようとしている場合は、要素内に含まれる部分構造を一致させるためにcontainerQuery()を使用することができます"tagname"を指定して、の場合はElementAttributeの場合はvalue()の制約を使用し、Elementtagnameの場合はvalue()という制約の値を使用して値 "Sample"のand()を使用します。

// 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); 
関連する問題