2011-07-14 12 views
1

テキストベースのフィールドタイプの強調表示を有効にしましたが、非テキストフィールドタイプの強調表示はできませんでした...Solr/SolrJ:どのように非テキストフィールドを強調表示しますか?

どのように非テキストフィールドタイプを強調表示するようにsolrを構成しますか?私は非テキストフィールドのWeb上の例を見つけることができません。それも可能ですか?

具体的には、クエリに合致するドキュメントのDate値を強調表示します。

solrJを使用してクエリを実行していますが、それが制限要因になる可能性がありますか?

答えて

2

「テキスト」以外のフィールドではハイライト表示できません。これを見て:

/** 
    * Returns a collection of the names of all stored fields which can be 
    * highlighted the index reader knows about. 
    */ 
    public Collection<String> getStoredHighlightFieldNames() { 
    if (storedHighlightFieldNames == null) { 
     storedHighlightFieldNames = new LinkedList<String>(); 
     for (String fieldName : fieldNames) { 
     try { 
      SchemaField field = schema.getField(fieldName); 

特にここに:

  if (field.stored() && 
        ((field.getType() instanceof org.apache.solr.schema.TextField) || 
        (field.getType() instanceof org.apache.solr.schema.StrField))) { 

ここ

  storedHighlightFieldNames.add(fieldName); 
      } 
     } catch (RuntimeException e) { // getField() throws a SolrException, but it arrives as a RuntimeException 
      log.warn("Field \"" + fieldName + "\" found in index, but not defined in schema."); 
     } 
     } 
    } 
    return storedHighlightFieldNames; 
    } 
+0

ありがとうございます!しかし、恐れがあります:( – Moogie

+1

どのような非テキストフィールドがドキュメントにクエリを満たすのかを特定する方法はありますか? – Moogie

+0

おそらく、非テキストフィールドがクエリの一部と一致していることを意味します。 – fyr

0

説明したようにあなたがこれを行うことはできませんまで。

しかし、これを処理するためにSolrを適応させるのは非常に簡単です。あなたの日付のための別のフィールドを文字列形式で作成します。今だけcopyFieldを使用します。

<field name="date1" type="date" indexed="true" stored="true" /> 
<field name="date1_str" type="string" indexed="true" stored="true" /> 

<copyField source="date1" dest="date1_str"/> 

は、それからちょうどあなたのクエリにフィールドdate1_strを追加します。

関連する問題