当前位置: 动力学知识库 > 问答 > 编程问答 >

SOLR managed-schema, how to use it?

问题描述:

I got my SOLR to work, and it works decently but i have no clue what exactly managed-schema is, since I did use the default version in which i added few lines that i needed for my case

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />

<field name="name" type="text_general" indexed="true" stored="true" default="" />

<field name="brand_id" type="string" indexed="true" stored="true" required="true" multiValued="false" />

<field name="brand_name" type="text_general" indexed="true" stored="true" default="" />

<field name="type" type="string" indexed="true" stored="true" required="true" default="0" />

I cannot include the full file because is like 700 lines...

but full xml is here http://pastebin.com/Z9nc36QD

do i have to keep everything as the default example? i have no clue...

do you have an example of a typical schema file?

网友答案:

The Managed Schema is supposed to be manipulated through the Schema API and not by editing the files present (which include a warning about doing so). The schema.xml file is only read once at the first time of startup to create the initial schema, any changes after that has to be done through the Schema API.

If you want to use a schema.xml file like the older Solr versions does without any Schema API support, you can use the ClassicIndexSchemaFactory in your solrconfig.xml file. See the Schema Factory Definition:

<schemaFactory class="ClassicIndexSchemaFactory"/>

An alternative to using a managed schema is to explicitly configure a ClassicIndexSchemaFactory. ClassicIndexSchemaFactory requires the use of a schema.xml configuration file, and disallows any programatic changes to the Schema at run time. The schema.xml file must be edited manually and is only loaded only when the collection is loaded.

You only need to keep the parts of the schema that you actually use, and the example schema (depending on which schema a user starts out with) will usually have many, many fields and fieldtypes that you don't need. These can be removed until they are needed, and the field types can be tweaked to enable the features that you want.

Do however remember that a change to the schema will require the content to be reindexed, so that the changes will be visible when searching.

Exact schema design is something you'll have to work with and experiment with, so that you're able to get the query profile and features for matching that you need.

分享给朋友:
您可能感兴趣的文章:
随机阅读: