2017-09-23 10 views
1
var marklogic=require('marklogic'); 
var ins=marklogic.createDatabaseClient({'host':'localhost','port':'7010','user':'admin','password':'admin',}); 
var qb=marklogic.queryBuilder; 
ins.documents.query(
    qb.propertiesFragment(
    qb.value("Author","Akhilesh Sabbisetti")) 
).result(function(matches){ 
    matches.forEach(function(match){ 
     console.log(match.uri); 
    }); 
    }); 

上記のコードは、文書のプロパティでのみ機能するはずですが、そのようには機能しませんでした。私は無関係の結果を得ていた。あなたはqb.where()方法を逃している....MarkLogicで文書のプロパティを検索するノードコード

+0

非常に小さな2つのドキュメントを使用してケースを再現できますか? – grtjn

答えて

5

を自分のコードを修正してください:

var marklogic=require('marklogic'); 
var ins=marklogic.createDatabaseClient({'host':'localhost','port':'7010','user':'admin','password':'admin',}); 
var qb=marklogic.queryBuilder; 
ins.documents.query(
qb.where(
    qb.propertiesFragment(
    qb.value("Author","Akhilesh Sabbisetti")) 
) 
).result(function(matches){ 
    matches.forEach(function(match){ 
     console.log(match.uri); 
    }); 
    }); 

はまた、私はあなたが次の形式で約束解決処理パターンを使用すると、同様のエラーをキャッチするために許可することを勧告することができます:

db.documents.query(
    qb.where(
    qb.propertiesFragment(
     qb.value('Author', 'Akhilesh Sabbisetti') 
    ) 
) 
) 
.result() 
.then(function(matches) { 
    console.log(matches); 
}) 
.catch(function(error) { 
    console.log(error); 
}); 
関連する問題