2013-02-12 61 views
1

我有兩個動態字段,如「產品名稱-*」* 「產品評級- *」。 一個文檔可以包含5個產品和相應的評分,如下所示。動態字段搜索

<str name="Product-Name-0">HTC Wildfire S</str> 
<str name="Product-Name-1">Samsung Tab 2</str> 
<str name="Product-Name-2">Samsung Note</str> 
<str name="Product-Name-3">IPhone5</str> 
<str name="Product-Name-4">Nokia Lumia 720</str> 
<int name="Product-Rating-0">5</int> 
<int name="Product-Rating-1">9</int> 
<int name="Product-Rating-2">7</int> 
<int name="Product-Rating-3">9</int> 
<int name="Product-Rating-4">9</int> 

在我目前的scnario,我必須提高具有較高的評價(只有更多的則6.Note評級將是10 1之間)的產品。 如果我想搜索例如「iPhone5的」一個perticular產品名稱,那麼我quering這樣

(Product-Name-0:IPhone5 AND (Product-Rating-0:7^3 OR Product-Rating-0:8^4 OR Product-Rating-0:9^5 OR Product-Rating-0:10^6)) OR 
(Product-Name-1:IPhone5 AND (Product-Rating-1:7^3 OR Product-Rating-1:8^4 OR Product-Rating-1:9^5 OR Product-Rating-1:10^6)) OR 
(Product-Name-2:IPhone5 AND (Product-Rating-2:7^3 OR Product-Rating-2:8^4 OR Product-Rating-2:9^5 OR Product-Rating-2:10^6)) OR 
(Product-Name-3:IPhone5 AND (Product-Rating-3:7^3 OR Product-Rating-3:8^4 OR Product-Rating-3:9^5 OR Product-Rating-3:10^6)) OR 
(Product-Name-4:IPhone5 AND (Product-Rating-4:7^3 OR Product-Rating-4:8^4 OR Product-Rating-4:9^5 OR Product-Rating-4:10^6)) 

我可以用產品名 - *:iphone5的找到所有的文件,但問題是我不知道如何根據其產品評級來提升該產品。

任何人都可以指導我是否遵循正確的方法嗎?

還有沒有其他的方法來實現這個目標?

在此先感謝。

+0

如果您嘗試在字段名稱中使用通配符(至少它發生在我的安裝中),您可能會得到解析錯誤 您能告訴我們您正在使用哪個solr版本嗎? – stephanruhl 2013-02-13 02:35:00

+0

我正在使用SOLR 4.0 Alpha。 – Ppm 2013-02-13 05:30:38

+0

有沒有辦法將上面的查詢轉換成edismax? – Ppm 2013-02-14 04:45:53

回答

0

我認爲你的模式設計本身有問題,爲什麼單個文檔中有多個名稱和評級。理想情況下,每個名稱都應該是獨立的文檔,並且具有自己的評級,這樣您就可以使用評估值本身的某些功能來提升它。

+0

沒有umar.it的僅僅是一個例子schema.As據我所知架構是所有fine.You可以採取studentinfo的例子像下面 <海峽NAME =「主題名稱-0」>科學 <海峽名稱= 「主題名稱-1」>數學 經濟學 歷史 地理 50 90 70 90 90 如果用戶搜索主題名稱,我需要提高那些有更多分數的文檔。 – Ppm 2013-02-13 19:30:25