2016-09-15 5 views
1

ここではMarklogicデータベースに接続し、文字列キーワードを使用してドキュメントを取得するJavaプログラムを作成しています。以下は作成されたプログラムです。MarklogicのJAVA APIを使用した検索の作成

import com.marklogic.client.DatabaseClient; 
import com.marklogic.client.DatabaseClientFactory; 
import com.marklogic.client.DatabaseClientFactory.Authentication; 
import com.marklogic.client.document.BinaryDocumentManager; 
import com.marklogic.client.document.JSONDocumentManager; 
import com.marklogic.client.document.TextDocumentManager; 
import com.marklogic.client.document.XMLDocumentManager; 
import com.marklogic.client.io.Format; 
import com.marklogic.client.io.StringHandle; 
import com.marklogic.client.query.QueryManager; 
import com.marklogic.client.query.StringQueryDefinition; 

public class dcb_conn { 
    public static void main(String args[]){ 
    DatabaseClient client = DatabaseClientFactory.newClient("localhost", 8004, "venkatesh", "F1mas", Authentication.DIGEST); 
    BinaryDocumentManager binDocMgr = client.newBinaryDocumentManager(); 
    XMLDocumentManager XMLdocMgr = client.newXMLDocumentManager(); 
    JSONDocumentManager JSONDocMgr = client.newJSONDocumentManager(); 
    TextDocumentManager TextDocMgr = client.newTextDocumentManager(); 
    QueryManager queryMgr = client.newQueryManager(); 
    StringQueryDefinition query = queryMgr.newStringDefinition(); 
    StringHandle resultsHandle = new StringHandle().withFormat(Format.XML); 
    query.setCriteria("Venkatesh"); 
    queryMgr.search(query, resultsHandle); 
    } 
} 

ドキュメントの結果(ABC.xmlなど)が表示されず、代わりに以下の結果が表示されます。私がここで紛失していることについて助言してもらえますか?

10:24:36.139 [main] DEBUG c.m.client.DatabaseClientFactory - Creating new database client for server at localhost:8004 
10:24:36.155 [main] DEBUG c.m.client.impl.JerseyServices - Connecting to localhost at 8004 as venkatesh 
10:24:36.319 [main] DEBUG c.m.client.impl.JerseyServices - Searching for Venkatesh 

答えて

4

このような場合は、まず、検索に使用しているユーザーと問題のドキュメントを読むことができるようにしてください。私は通常、ドキュメントを取得することができますが、これは言語設定のために失敗する可能性があります。

ので、短い提案が可能とユーザ(クエリコンソールおよび/またはRESTなど)を備えたMLに対して直接テストなど、多くの可動部品として-removeある

+2

はまた、あなたの検索は大文字を持っていることに注意してくださいこれはデフォルトで大文字と小文字が区別されることを意味します([cts:word-queryの使用上の注意](http://docs.marklogic.com/cts:word-query)を参照してください)。または小文字のクエリを使用してください –

+0

Davidさんありがとうございます私は以下のようにプログラムを修正して、結果を表示しています DatabaseClient client = DatabaseClientFactory.newClient( "localhost"、8004、 "admin"、 "admin" 、Authentication.DIGEST); \t \t QueryManager queryMgr = client.newQueryManager(); \t \t StringQueryDefinition query = queryMgr.newStringDefinition(); \t \t SearchHandle resultsHandle = new SearchHandle(); \t \t query.setCriteria( "Venkatesh"); \t \t //検索を実行します。 \t \t \t queryMgr.search(query、resultsHandle); \t \t //結果をフォーマットします。 \t \t \t TutorialUtil.displayResultURIs(resultsHandle); \t \t \t client.release(); \t} } – V3nky

+0

また、Java APIを使用してGUIを構築する場合、ドキュメント名を使用してドキュメントを検索する方法について質問があります。お知らせ下さい。 – V3nky

関連する問題