Use SOLR to build enterprise search platform 3 (configuration file)

Source: Internet
Author: User
Tags solr
Running SOLR is a simple task. It is not easy to make SOLR run your project efficiently. There are too many factors to consider. It is important to understand SOLR configurations. Understand the meaning of each configuration item in the configuration file!

In SOLR, schema. xml and solrconfig. xml under the SOLR main directory are used. If you have read the first two articlesArticleYou should know where the SOLR home directory is (C: \ SOLR-Tomcat \ SOLR \ conf \).

In this article, we will first talk about this schema. xml.

Schema. XML, which is equivalent to the data table configuration file, which defines the data type of the data to be indexed. It mainly includes types, fields, and other default settings.

1. Define a fieldtype subnode in the types node, including parameters such as name, class, and positionincrementgap. Name is the name of fieldtype, and class points to Org. apache. SOLR. the class name corresponding to the analysis package, used to define this type of behavior. When fieldtype is defined, the most important thing is to define the analyzer used to index and query data of this type, including word segmentation and filtering. In this example, the fieldtype text is defined and SOLR is used in the index analyzer. whitespacetokenizerfactory is a space word segmentation package, and then SOLR is used. stopfilterfactory, SOLR. worddelimiterfilterfactory, SOLR. lowercasefilterfactory, SOLR. englishporterfilterfactory, SOLR. removeduplicatestokenfilterfactory filters. When a text index is added to the index library, SOLR first uses spaces for word segmentation, and then filters the word segmentation results using the specified filter in sequence, the remaining results will be added to the index database for query. The analysis package of SOLR does not contain a package that supports Chinese characters. The second article details how to add a paoding Chinese Word divider. For more information, see http://lianj-lee.javaeye.com/blog/424474.

2. The next step is to define a specific field (similar to a field in a database) in the fields node, that is, filed. The filed definition includes name, type (defined previously), indexed (indexed or not), stored (stored or not), multivalued (whether there are multiple values), and so on.
Example: XML Code

  1. <Fields>
  2. <Field Name="ID" Type="Integer" Indexed="True" Stored="True" Required="True" />
  3. Field name = "name" type = "text" indexed = " true " stored = "true" />
  4. Field name = "summary" type = "text" indexed = " true " stored = "true" />
  5. Field name = "author" type = "string" indexed = " true " stored = "true" />
  6. Field name = "date" type = "date" indexed = " false " stored = "true" />
  7. Field name = "content" type = "text" indexed = " true " stored = "false" />
  8. Field name = "keywords" type = "keyword_text" indexed = " true " stored = "false" multivalued = "true" />
  9. <Field Name="All" Type="Text" Indexed="True" Stored="False" Multivalued="True"/>
  10. </Fields>
<Fields> <field name = "ID" type = "integer" indexed = "true" stored = "true" required = "true"/> <field name = "name" Type = "text" indexed = "true" stored = "true"/> <field name = "summary" type = "text" indexed = "true" stored = "true"/> <field name = "author" type = "string" indexed = "true" stored = "true"/> <field name = "date" type = "date" indexed = "false "Stored =" true "/> <field name =" content "type =" text "indexed =" true "stored =" false "/> <field name =" keywords "Type = "keyword_text" indexed = "true" stored = "false" multivalued = "true"/> <field name = "all" type = "text" indexed = "true" stored = "false" multivalued = "true"/> </fields>

Field definition is very important. There are several tips to note that you should try to set the multivalued attribute to true for multiple worthwhile fields to avoid index creation errors; if you do not need to store the corresponding field values, set the stored attribute to false.

3 "it is recommended that a copy field be created to copy all full-text fields to one field for unified search: XML Code

    1. <Field Name="All" Type="Text" Indexed="True" Stored="False" Multivalued="True"/>
 
<Field name = "all" type = "text" indexed = "true" stored = "false" multivalued = "true"/>

complete the copy settings at the copy field node: XML Code

    1. <Copyfield Source="Name" Dest="All"/>
    2. <Copyfield Source="Summary" Dest="All"/>
 
<Copyfield source = "name" DEST = "all"/> <copyfield source = "summary" DEST = "all"/>

4. Dynamic fields can also be defined. Dynamic fields do not need to be specified. As long as the rules for field names are defined, for example, a dynamicfield with name * _ I, define its type as text, so when using this field, any field ending with _ I is considered to comply with this definition, for example: name_ I, gender_ I, school_ I.

The schema. xml configuration file is basically like this. For more details, see SOLR wiki http://wiki.apache.org/solr/schemaxml. If you have time later, I will update this article on a regular basis to facilitate more beginners.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.