2009-12-29 100 views
8

我遇到了Solr和Faceting問題,並想知道是否有人知道該修復。我現在有一個工作,但我真的想弄清楚爲什麼我的查詢不起作用。使用「字符串」字段,「文本」字段和「複製」字段對Solr進行切分

這裏是我的架構,簡化,使之更容易遵循:

<fields> 
    <field name="uniqueid" type="string" indexed="true" required="true"/> 
    <!-- Indexed and Stored Field ---> 
    <field name="recordtype" type="text" indexed="true" stored="true"/> 
    <!-- Facet Version of fields --> 
    <field name="frecordtype" type="string" indexed="true" stored="false"/> 
</fields> 

<!-- Copy fields for facet searches --> 
<copyField source="recordtype" dest="frecordtype"/> 

正如你可以看到我有一個區分大小寫的字段名爲RECORDTYPE和它被複制到一個大小寫敏感領域frecordtype不記號化的文本。這是因爲solr在分面結果中返回索引值而不是存儲值。

當我嘗試以下查詢:

http://localhost:8080 
/solr 
/select 
?version=2.2 
&facet.field=%7b!ex%3dfrecordtype%7dfrecordtype 
&facet=on 
&fq=%7b!tag%3dfrecordtype%7dfrecordtype%3aLarge%20Record 
&f1=*%2cscore 
&rows=20 
&start=0 
&qt=standard 
&q=text%3a%25 

我沒有得到任何結果,但是facteting仍然顯示還有1分的紀錄。

<result name="response" numFound="0" start="0" /> 
<lst name="facet_counts"> 
    <lst name="facet_queries" /> 
<lst name="facet_fields"> 
<lst name="frecordtype"> 
    <int name="Large Record">1</int> 
    <int name="Small Record">12</int> 
    <int name="Other">1</int> 
    </lst> 
    </lst> 
    <lst name="facet_dates" /> 
    </lst> 

但是,如果我改變fitler查詢(行7只),是對 「RECORDTYPE」 insted的frecordtype的:

http://localhost:8080 
/solr 
/select 
?version=2.2 
&facet.field=%7b!ex%3dfrecordtype%7dfrecordtype 
&facet=on 
&fq=%7b!tag%3dfrecordtype%7drecordtype%3aLarge%20Record 
&f1=*%2cscore 
&rows=20 
&start=0 
&qt=standard 
&q=text%3a%25 

我得到的1個結果回來,我想。

<result name="response" numFound="1" start="0" /> 
<lst name="facet_counts"> 
    <lst name="facet_queries" /> 
<lst name="facet_fields"> 
<lst name="frecordtype"> 
    <int name="Large Record">1</int> 
    <int name="Small Record">12</int> 
    <int name="Other">1</int> 
    </lst> 
    </lst> 
    <lst name="facet_dates" /> 
    </lst> 

所以我的問題是,有什麼我需要做的,以獲得第一個版本的查詢返回我想要的結果?也許這是關於URL編碼或什麼的?來自某個solr guru或其他人的任何提示都將非常感激。

注意:這是不必要的一個小面的問題,因爲面的實際工作。這更多的是一個查詢問題,我無法在「字符串」字段上執行查詢,即使大小寫和間距與索引版本完全相同。

編輯:有關小平面,你可以看看這些博客文章關於它的更多信息:

感謝

戴夫

+0

Arrhhh排序了這一點......你需要引號與空間:) – CraftyFella 2009-12-29 13:58:27

回答

10

您需要引用值爲

例如

frecordtype:「大型唱片」

工作

frecordtype:大型唱片

這將爲大型的frecordtype搜索,這將帶回什麼..然後記錄整個默認領域Solr的。

相關問題