Initial SOLRJ development and Schema.xml configuration and service initialization.

Source: Internet
Author: User
Tags filter lowercase solr

Schema.xml is located in the solr/collection1/conf/directory and is the configuration file for user-defined field types and fields in SOLR.

SOLR version: 4.6.0

The first step: Schema.xml description

The example Schema.xml structure is consistent with the solr/collection1/conf/schema.xml structure, and the specific configuration is indicated by the annotation.

<?xml version= "1.0" encoding= "UTF-8"?> <schema name= "Example" version= "1.5" > <fields> <!--
         Field Property Description: The filed field is used to define the type of search and related settings used by the Data source field.
         Name: The data source field name, which is used by the search.
         Type: Search for a kind name such as Chinese Ika search name Text_ika, corresponding to name in FieldType. String types that do not need to be participle, string can be, if you need to participle, types in the configuration of a good word type.
         Indexed: Indexed, only fields set to true can be searched for sort fragmentation (earchable, sortable, facetable).
         Stored: whether to store content, if you do not need to store field values, try to set to false to improve efficiency. Multivalued: is a multivalued type, SOLR allows you to configure multiple data source fields to be stored in a search field.
     Multiple values must be true, otherwise it is possible to throw an exception. --> <field name= "id" type= "string" indexed= "true" stored= "true" required= "true"/> <field n Ame= "name" type= "Text_ik" indexed= "true" stored= "true" multivalued= "false"/> <field name= "Phone" type= "string" Indexed= "false" stored= "true"/> <field name= "Email" type= "string" indexed= "false" stored= "true" multivalued= "t Rue "/> <field name=" city_id "type=" "true" indexed= "true" stored=/> <field "Address" tYpe= "Text_ik" index= "true" stored= "true"/> <field name= "All" type= "string" index= "true" stored= "true"/>
    <!--dynamic field definitions define--> <dynamicfield name= "*_i" type= "int" indexed= "true" stored= "true"/> <dynamicfield name= "*_s" type= "string" indexed= "true" stored= "true"/> </fields> <!--Uni
    The Quekey node sets the primary key, and SOLR must have a primary key, which is generally defined by its ID. 
    This field determines and enhances the uniqueness of the document--> <uniqueKey>id</uniqueKey> <!--defaultsearchfield node default search field, the default value is text, If we have copied the fields that need to be searched to the all field, we can set all to--> <defaultSearchField>text</defaultSearchField> <!--
    Solrqueryparser node default search operator parameters, and search phrase logic, with and to increase the accuracy rate, with or to increase coverage, proposed with and, can also be defined in search statements. For example, search for "Java multithreading", using and default search for "Java and multithreading"--> <solrqueryparser defaultoperator= "OR"/> <!--copyfield node if
What do we do when we search for more than one field? At this point, we can use the Copyfield node, we will all of the Chinese word segmentation field all copied to all, when we do full-text search is, only use the searching all field OK. --> <copyfield source= "name" dest= "All"/> <copyfield source= "Phone" dest= "all"/> <copyfield source= "emails" dest= "all"/> <types> &l t;! --Defines the field processing type--> <fieldtype name= "int" class= "SOLR". Trieintfield "precisionstep=" 0 "omitnorms=" true "positionincrementgap=" 0 "/> <fieldtype" name= "float" class= "sol R.triefloatfield "precisionstep=" 0 "omitnorms=" true "positionincrementgap=" 0 "/> <fieldtype" Double "class = "SOLR." Triedoublefield "precisionstep=" 0 "omitnorms=" true "positionincrementgap=" 0 "/> <fieldtype \ Name=" string "class= "SOLR. Strfield "sortmissinglast=" true "omitnorms=" true "/> <fieldtype name=" text "class=" SOLR. TextField "positionincrementgap=" > <analyzer> <tokenizer class= "SOLR."
    Whitespacetokenizerfactory "/> </analyzer> </fieldType> <!--defines general classification of--> <fieldtype name= "text_general" class= "SOLR." TextField "positionincrementgap=" > &Lt;! --The word breaker configuration when indexing--> <analyzer type= "index" > <!--indexing using standard word breaker--> <tokenizer clas S= "SOLR. Standardtokenizerfactory "/> <!--deactivate word filter, used to index documents in the Deactivate Word to remove--> <filter class=" SOLR. Stopfilterfactory "ignorecase=" true "words=" Stopwords.txt "/> <!--uppercase to lowercase filter--> <filter class= "SOLR. Lowercasefilterfactory "/> </analyzer> <!--query using the word breaker--> <analyzer type = "Query" > <!--Query index using standard word breaker--> <tokenizer class= "SOLR. Standardtokenizerfactory "/> <!--deactivate word filter, used to index documents in the Deactivate Word to remove--> <filter class=" SOLR. Stopfilterfactory "ignorecase=" true "words=" Stopwords.txt "/> <!--define queries using synonym Filters--> R class= "SOLR.
        Synonymfilterfactory "synonyms=" Synonyms.txt "ignorecase=" true expand= "true"/> <!--uppercase to lowercase filter--> <filter class= "SOLR. Lowercasefilterfactory "/> &Lt;/analyzer> </fieldType> <!--define IK--> <fieldtype name= "Text_ik" class= " Solr. TextField "> <!--the index of the word breaker--> <analyzer type=" index "ismaxwordlength=" false "class=" Org.wltea. Analyzer.lucene.IKAnalyzer "/> <!--the word breaker--> <analyzer type=" Query "ismaxwordlength=" true "cl ass= "Org.wltea.analyzer.lucene.IKAnalyzer"/> </fieldType> </types> </schema>

In the default Solr/collection1/conf/schema.xml file, there is the following field setting, where title is configured to allow multiple values, so we can use the collection to mark the abstract class.

<field name= "id" type= "string" indexed= "true" stored= "true" required= "true" multivalued= "false"/>
<field name= "title" Type= "Text_general" indexed= "true" stored= "true" multivalued= "true"/>
<field name= "Author" type= "Text_general" indexed= "true" stored= "true"/>

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.