1

テキストベースのフィールドタイプで強調表示を有効にすることに成功しましたが、非テキストフィールドタイプでは有効にできませんでした...

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

具体的には、クエリに一致するドキュメントの日付値を強調表示したいと思います。

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

4

2 に答える 2

3

「テキスト」フィールド以外では強調表示できません。これを見てください:

/**
   * 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;
  }
于 2011-07-14T08:07:36.033 に答える
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をクエリに追加します。

于 2012-02-16T17:50:30.033 に答える