7

Is there any Solr API to read the Solr schema.xml?

The reason I need it is that Solr faceting is not backwards compatible. If the index doesn't define field A, but the program tries to generate facets for field A, all the facets will fail. Therefore I need to check in the runtime what fields we have in the index, and generate the facets dynamically.

4

4 に答える 4

5

Solr 4.2 以降、スキーマ REST API を使用すると、次の方法でスキーマを取得できます。

http://localhost:8983/solr/schema

またはコア名で:

http://localhost:8983/solr/mycorename/schema

Solr 4.4 以降、スキーマを変更することもできます。

Solr Wiki ページの詳細

于 2013-09-18T13:59:20.177 に答える
4

でスキーマを取得できますhttp://localhost:8983/solr/admin/file/?contentType=text/xml;charset=utf-8&file=schema.xml

これは生の xml であるため、必要な情報を取得するには解析する必要があります。

ただし、プログラムが無効なファセットを生成する場合は、これを回避しようとするのではなく、プログラムを修正する必要があります。

于 2011-08-30T18:10:45.980 に答える
3

1 つの代替方法は、LukeRequestHandler を使用することです。これは、Lucene Index の内容を診断するために使用されるLukeツールをモデルにしています。/admin/luke?show=schema クエリを実行すると、スキーマが表示されます。ただし、次のように solrconfig.xml で定義する必要があります。

<requestHandler name="/admin/luke" class="org.apache.solr.handler.admin.LukeRequestHandler" />

LukeRequestHandlerリンクのドキュメント

于 2011-08-30T19:57:25.993 に答える