2016-08-28 29 views
0

我正在使用Solr 5.2,我有一個網站,內容較大(雙語),需要索引搜索功能,我需要索引一些元數據有關每個內容(類別,標題,日期,...),並且我還需要根據您的知識和經驗爲網頁的內容編制索引,將單個字段中的所有字段複製並使用此字段進行搜索是正確的,我現在正在執行以下操作Solr大型內容網站

<fieldType name="compound_text" class="solr.TextField" positionIncrementGap="100" multiValued="true"> 
    <analyzer> 
     <tokenizer class="solr.StandardTokenizerFactory"/> 
     <filter class="solr.StopFilterFactory" words="lang/stopwords_en.txt" ignoreCase="true"/> 
     <filter class="solr.StopFilterFactory" words="lang/stopwords_ar.txt" ignoreCase="true"/> 
     <filter class="solr.ArabicNormalizationFilterFactory"/> 
     <filter class="solr.LowerCaseFilterFactory"/> 
    </analyzer> 
</fieldType> 
<field name="compound_text_field" type="compound_text" multiValued="true" indexed="true" stored="true"/> 
<field name="author_name"   type="strings" indexed="false" stored="false"/> 
<field name="category"   type="strings" indexed="false" stored="true"/> 
<field name="content_ar"   type="strings" indexed="false" stored="true"/> 
<field name="content_en"   type="strings" indexed="false" stored="true"/> 
<field name="content_title"  type="compound_text" indexed="true" stored="true" multiValued="true"/> 
<field name="publish_date" type="tdate"/> 
<copyField source="content_ar" dest="compound_text_field"/> 
<copyField source="content_en" dest="compound_text_field"/> 
<copyField source="content_title" dest="compound_text_field"/> 
<copyField source="source" dest="compound_text_field"/> 
<copyField source="category" dest="compound_text_field"/> 
<copyField source="author_name" dest="compound_text_field"/> 
<fieldType name="text_suggest" class="solr.TextField" positionIncrementGap="100"> 
    <analyzer> 
     <tokenizer class="solr.StandardTokenizerFactory"/> 
     <filter class="solr.ArabicNormalizationFilterFactory"/> 
     <filter class="solr.LowerCaseFilterFactory"/> 
    </analyzer> 
</fieldType> 
<field name="text_suggest_field" type="text_suggest" indexed="true" stored="true"/> 
<copyField source="content_title" dest="text_suggest_field> 
+0

如果您更好地使用多種語言,可以爲每種語言使用不同的索引,或者在一種索引中使用不同語言的不同字段。在這裏,您正在將content_en(英文字段)複製到具有arabicfilterfactory的單個字段。 – vinod

回答

0

有幾種方法可以做到這一點。請參見什麼適合你的應用程序...

  1. 在conf/schema.xml中添加新字段,它充當您想要搜索的所有字段的串聯。將該字段設置爲xml文件中的defaultSearchField,然後發送沒有字段名稱的查詢。您可以使用copyField將值複製到拼接字段。

  2. 您可以使用不同的查詢字符串,然後將它們包括爲由空格分隔的「field:query」對。

這完全取決於用例。

+0

編號1正是我採取的方法,請參閱我的架構中的compound_text_field,但將阿拉伯文內容和英文內容添加到同一字段是否正確? – Moon123