2012-05-16 101 views
0

我已經包含三個專利委派標籤搜索:搜索API不返回正確的輸出

<patent-assignments> 
    <patent-assignment> 
    <patent-assignors> 
     <patent-assignor> 
      <name>TSAI, YU-WEN</name> 
     </patent-assignor> 
     </patent-assignors> 
     <patent-assignees> 
     <patent-assignee> 
      <name>FARADAY TECHNOLOGY CORP.</name> 
     </patent-assignee> 
     </patent-assignees> 
    </patent-assignment> 

    <patent-assignment> 
    <patent-assignors> 
     <patent-assignor> 
      <name>APPLE</name> 
     </patent-assignor> 
     </patent-assignors> 
     <patent-assignees> 
     <patent-assignee> 
      <name>GOOGLE INC</name> 
     </patent-assignee> 
     </patent-assignees> 
    </patent-assignment> 

    <patent-assignment> 
    <patent-assignors> 
     <patent-assignor> 
      <name>GOOGLE INC</name> 
     </patent-assignor> 
     </patent-assignors> 
     <patent-assignees> 
     <patent-assignee> 
      <name>FARADAY TECHNOLOGY CORP.</name> 
     </patent-assignee> 
     </patent-assignees> 
    </patent-assignment> 
</patent-assignments> 

現在下面的XML文檔,當我運行以下搜索查詢: -

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

declare variable $options:= 
    <options xmlns="http://marklogic.com/appservices/search"> 
    <transform-results apply="raw"/> 
    </options>; 

search:search("apple", $options, 1, 1)/search:result 

我得到的完整文檔作爲輸出,但匹配單詞「APPLE」僅在xml的第二個專利分配標籤中。我只想得到第二份專利轉讓,而不是完整的文件。如果我使用代碼段,那麼它會顯示文檔和元素名稱,以查找匹配項,但是它沒有返回實際輸出。我想要那個特定的專利分配標籤作爲找到匹配詞的輸出。

回答

3

Puneet,搜索:搜索功能正在做它正在配置的功能,從這個意義上說,響應是正確的。你只需要對你要求做的事情做一點改變。試試這個:

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

declare variable $options:= 
    <options xmlns="http://marklogic.com/appservices/search"> 
    <transform-results apply="raw"/> 
    <searchable-expression>/patent-assignments/patent-assignment</searchable-expression> 
    </options>; 

search:search("apple", $options, 1, 1)/search:result 

加入搜索表達式元素,我回來只是專利轉讓與查詢匹配元素後:

<search:result index="1" uri="/patent.xml" path="fn:doc(&quot;/patent.xml&quot;)/patent-assignments/patent-assignment[2]" score="43008" confidence="0.664889" fitness="0.664889" xmlns="" xmlns:search="http://marklogic.com/appservices/search"> 
    <patent-assignment> 
    <patent-assignors> 
     <patent-assignor> 
     <name>APPLE</name> 
     </patent-assignor> 
    </patent-assignors> 
    <patent-assignees> 
     <patent-assignee> 
     <name>GOOGLE INC</name> 
     </patent-assignee> 
    </patent-assignees> 
    </patent-assignment> 
</search:result> 
+0

感謝ü非常 –