2015-07-03 45 views
1

我花了大部分時間嘗試將方面添加到基於marklogic slush template的示例應用程序。在slog marklogic示例中添加一個方面

它基於元素範圍索引在eyeColor上有一個方面。

樣本數據可以發現here

我的目標是添加關於性別一個刻面,這也是在本例中JSON數據的元件。所以我在localname gender上添加了一個元素範圍索引。相同的整理端點。

然後我重建索引

現在我試着去理解,如果我需要在前端應用程序的其他變化方面的應用輪番上漲之前。

從後端開始,我嘗試瞭解如何使用控制檯上的示例xquery查看搜索調用中可用的方面(或約束)。似乎我找不到正確的搜索:搜索功能從控制檯檢索facet信息,甚至不是eyeColor上的現有信息。

如果我知道我想要什麼,我可以在選項參數中傳遞一個約束,但似乎前端不知道search-api返回的具體構面還是我錯了?

在控制檯我想:

xquery version "1.0-ml"; 
import module namespace search = "http://marklogic.com/appservices/search" 
    at "/MarkLogic/appservices/search/search.xqy"; 

search:search(" ", 
    <options xmlns="http://marklogic.com/appservices/search"> 
     <return-results>true</return-results> 
     <return-facets>true</return-facets> 
     <constraint name="eyeColor"> 
    <range collation="http://marklogic.com/collation/codepoint/" type="xs:string"> 
    </range> 
    </constraint> 
    </options>) 

但不包含小結果...

是的,我讀的大部分就在這裏ML方面存在的問題,在SO,但沒有運氣依然..

任何人都可以在這裏設置正確的軌道嗎?

雨果

+0

OK就休息終點可以看我的眼睛顏色約束現在的http:// ML8基毫升1:8050/v1/config/query/all –

回答

1

好,我知道了...... 您必須將選項添加到該文件夾​​的應用程序根/ REST的API /配置/選項REST API選項/ all.xml

添加一個選項(性別)像

<search:constraint name="gender"> 
    <search:range type="xs:string" facet="true" collation="http://marklogic.com/collation/codepoint"> 
     <search:facet-option>limit=5</search:facet-option> 
     <search:facet-option>frequency-order</search:facet-option> 
     <search:facet-option>descending</search:facet-option> 
     <search:json-property>gender</search:json-property> 
    </search:range> 
    </search:constraint> 

部署再次使用樂聲,rmeber還需要一系列指數...

+0

是的,在範圍索引旁邊,需要添加facet = true的搜索約束。把索引放在ml-config.xml和bootstrap中。將搜索約束放在all.xml中,並部署其餘(或模塊)。重建索引是沒有必要的。用戶界面會自動檢測多餘的方面。 – grtjn