我有Solr 4.10.0我已經爲某些書籍執行了索引。架構文件是每本書的頁數,所以每一個文檔具有諸如,PAGEID,的BookID,頁次,內容等在schema.xml中的字段的定義是這樣的:試圖從Solr搜索中獲得不同的字段值
<field name="PageID" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="Content" type="text_ar" indexed="true" stored="true" required="true" termVectors="true" />
<field name="PageNum" type="int" indexed="false" stored="true" required="false" multiValued="false" />
<field name="Part" type="int" indexed="false" stored="true" required="false" multiValued="false" />
<field name="BookID" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="BookTitle" type="text_ar" indexed="true" stored="true" required="true" />
<field name="BookInfo" type="text_ar" indexed="true" stored="true" required="true" />
<field name="BookCat" type="int" indexed="false" stored="true" required="false" multiValued="false" />
問題
當我嘗試搜索包含頁面文本的字段Content
時,我將從相同的Book
獲得多個結果。很明顯,這是預料之中的,因爲在書的許多頁面中可能會找到某個詞。我試圖讓SQL DISTINCT像類似下面的查詢:
使用
facet
的http://本地主機:8080/Solr的/書籍/選擇/ Q =內容:WordOfSearch &排序= PAGEID% 20desc &版本= 2.2 &開始= 0 &行= 10 &縮進=上&重量= JSON &面=上& facet.field =的BookID & facet.limit = 1 & HL =真& hl.q =含量:WordOfSear CH
在前面的查詢我設置facet.field=BookID
做的結果只能有一個結果,與同一本書。但是,此解決方案不能按預期方式工作,並返回結果,如不使用facet
。即使用方面沒有改變。
HTTP:
使用
group
餘使用和不使用參數main
像下面用它//本地主機:8080/solr的/書籍/選擇/ Q =內容:WordOfSearch &排序= PAGEID%20desc &版本= 2.2 &開始= 0 &行= 10 &縮進=上&重量= JSON &組=真& group.field =的BookID & group.main =真& HL =真& hl.fl = * & hl.simple.pre = & hl.simple.post = <%2Fspan>
的group
部分解決了這個問題。即從每個包含WordOfSearch的書籍內容 - 頁面 - 它返回一個結果。但是,它破壞了我在我的應用程序中所做的分頁。在應用程序中,我依靠response: numFound
來維護總記錄。在我使用的group
解決方案中,它返回numFound
等於沒有組的查詢中找到的數字。即它返回具有重複的BookID
值的文檔的數量,所以它在最後一次分頁時導致空頁面。所以,我怎樣才能得到group
返回文件的確切數字?或任何其他解決方案與我的問題重複BookID
字段值。
儘管我不關心具體的頁面,但我需要從每本書中至少找到一個頁面,在其內容中找到關鍵字。 – SaidbakR 2014-12-19 19:48:59