文系プログラマによるTIPSブログ

文系プログラマ脳の私が開発現場で学んだ事やプログラミングのTIPSをまとめています。

solr3.6の起動時のエラー:org.apache.solr.common.SolrException: undefined field text

solr3.6をダウンロードして、
example
 └solr
   └conf
のconfを使用していて、tomcatを起動すると、以下のエラーが発生します。
致命的: org.apache.solr.common.SolrException: undefined field text
なんだろうこれは。
schema.xmlを見てもよく解りません。んんん??
ではsolrconfig.xmlの方かな。ジーーーッと見てみる。

    <listener event="newSearcher" class="solr.QuerySenderListener">
      <arr name="queries">
      </arr>
    </listener>
    <listener event="firstSearcher" class="solr.QuerySenderListener">
      <arr name="queries">
        <lst>
          <str name="q">static firstSearcher warming in solrconfig.xml</str>
        </lst>
      </arr>
    </listener>

お前か!!
具体的には以下の部分です。

<str name="q">static firstSearcher warming in solrconfig.xml</str>

この設定がある事で、tomcat起動時にauto_warmingするため「static firstSearcher warming in solrconfig.xml」という
クエリーが投げられ、そんなfield無いよ、と言われていたのです。

普通クエリーって「*:*」みたいな感じですが、前述の文章がそのまま投げられていた訳です。

そもそもfirstSearcherとは何でしょうか。

A First Searcher is opened when there is _no_ existing (current) Searcher. In the example below, the listener is of the class, QuerySenderListener, which takes lists of queries and sends them to the new searcher being opened, thereby warming it. (If there is no Searcher, you cannot use auto-warming because auto-warming requires an existing Searcher.)

http://wiki.apache.org/solr/SolrConfigXml#firstSearcher

簡単に説明すると、auto_warmingするためにサーチャーのインスタンスを生成する為のクエリの設定です。
auto_warmingは、キャッシュやインスタンスが無いと、負荷がかかった際にダウンしてしまうため、
起動時にキャッシュ・インスタンスを生成しておく機能です。

では解決策ですが、「newSearcher」と「firstSearcher」を削除してしまう(auto_warmingでサーチャーを生成しない)か、
以下のようにクエリを正しく設定します。

<str name="q">static firstSearcher warming in solrconfig.xml</str>
↓こう修正する
<str name="q">*:*</str> <!-- これは大量の結果が返るので、適宜最適なクエリに書き換えましょう -->