2012-11-05 8 views
5

文書の文書プロパティを検索したい。私はMarklogicにロードされたドキュメントのみを持ち、xmlファイルはありません。私はコンテンツ処理を無効にしました。今、私はドキュメントのプロパティを検索するには?

xdmp:document-properties(uri)に存在する)のメタデータを検索したい私は、ドキュメント内の次のプロパティがあります。 -

<?xml version="1.0" encoding="UTF-8"?> 
<prop:properties xmlns:prop="http://marklogic.com/xdmp/property"> 
    <uploaded>true</uploaded> 
    <OntologyResourceTypeValue>DOCUMENT</OntologyResourceTypeValue> 
    <content-type>application/pdf</content-type> 
    <filter-capabilities>text subfiles HD-HTML</filter-capabilities> 
    <CreationDate>2002/12/05 09:44:29Z</CreationDate> 
    <ModDate>2002/12/05 12:02:27+02'00'</ModDate> 
    <Producer>Acrobat Distiller 5.0 (Windows)</Producer> 
    <Author>Administrator</Author> 
    <Creator>PScript5.dll Version 5.2</Creator> 
</prop:properties> 

は今、私は著者だけでなく、他のプロパティを検索したいです。 search:search("Administrator")を使用している場合は、ドキュメント全体でこの単語を探しています。しかし、私は、文書のプロパティでAuthorタグだけを検索したい。同様に私は他のプロパティでも検索したいと思う。

私もこの試みている: -

let $options := <options xmlns="http://marklogic.com/appservices/search"> 
          <constraint name="author"> 
         <properties name="prop:Author"/> 
         </constraint> 
        </options> 
    let $results := search:search("author:Administrator", $options, 1, 10) 
    return 
    $results 

しかし、これは動作しません。助けてください。

答えて

0

検索可能な式を設定する必要があると思います。このオプションを追加してみてください:

<searchable-expression>xdmp:document-properties()</searchable-expression> 
0

Fwiw、プロパティに到達するXPath軸もあります。

property::

0

プロパティの制約の問題は、それが断片のみスコープを変更し、ただ一つの特性に検索を制限するためにname属性を受け入れないこと、です。 <return-query>true</return-query>を追加すると、結果のクエリがどのように表示されるでしょう。しかし、いくつかのオプションがあります

..

最初のオプションは<fragment-scope>properties</fragment-scope>を使用することです。これをトップレベルで使用すると、すべての検索制約に適用できます。また、制約ごとに特定の制約のみに適用することもできます。これは、文書フラグメントの代わりにプロパティフラグメントに対して検索クエリを強制的に実行させる比較的簡単な方法です。下側は、検索マッチ、別名スニペットには影響しません。

スニペットに影響を与えるには、@mblakeleが示唆していることを行う方が良いですし、検索式-<searchable-expression>xdmp:document-properties()</searchable-expression>を使用する方が良いです。これは実際にスニペットと検索クエリの両方に影響するので、それを使用すると検索スニペットが取得され、クエリがプロパティフラグメント上で実行されます。著者の制約は依然としてAuthorプロパティに制限されません。

検索をプロパティフラグメントに渡すと、検索を特定のプロパティに限定することは、実際にはかなり簡単です。それは他の要素と同様に単なる要素です。その作業をするには、要素の単語、値、または範囲の制約を使用します。

xquery version "1.0-ml"; 

import module namespace search = "http://marklogic.com/appservices/search" 
    at "/MarkLogic/appservices/search/search.xqy"; 

(: original approach :) 
let $options1 := 
    <options xmlns="http://marklogic.com/appservices/search"> 
    <constraint name="author"> 
     <properties name="prop:Author"/> 
    </constraint> 
    <return-query>true</return-query> 
    </options> 
let $results1 := search:search("author:Administrator", $options1, 1, 1) 

(: using fragment-scope :) 
let $options2 := 
    <options xmlns="http://marklogic.com/appservices/search"> 
    <fragment-scope>properties</fragment-scope> 
    <constraint name="author"> 
     <properties name="prop:Author"/> 
    </constraint> 
    <return-query>true</return-query> 
    </options> 
let $results2 := search:search("author:Administrator", $options2, 1, 1) 

(: using searchable-expression :) 
let $options3 := 
    <options xmlns="http://marklogic.com/appservices/search"> 
    <searchable-expression>xdmp:document-properties()</searchable-expression> 
    <constraint name="author"> 
     <properties name="prop:Author"/> 
    </constraint> 
    <return-query>true</return-query> 
    </options> 
let $results3 := search:search("author:Administrator", $options3, 1, 1) 

(: using searchable-expression with an element word constraint :) 
let $options4 := 
    <options xmlns="http://marklogic.com/appservices/search"> 
    <searchable-expression>xdmp:document-properties()</searchable-expression> 
    <constraint name="author"> 
     <word> 
     <element name="Author" ns="http://marklogic.com/xdmp/property"/> 
     </word> 
    </constraint> 
    <return-query>true</return-query> 
    </options> 
let $results4 := search:search("author:Administrator", $options4, 1, 1) 

return (
    $results1, 
    $results2, 
    $results3, 
    $results4 
) 

4番目の例は、あなたが探していた結果を与える必要があります:上記を説明するためにいくつかのコードの下に

HTH!

関連する問題