SOLR Learning four--------Field, Copyfield, DynamicField

Source: Internet
Author: User
Tags abstract solr

The above section of the disorderly seven or eight slot of the talk about FieldType. In fact, you can think of it simply, FieldType is like we're customizing types in java.


Field:

field is just a field, and it's simple to define one:

<field name= "Price" type= "Sfloat" indexed= "true" stored= "true"/>

Essentially, the property is similar to FieldType, and his attributes override the FieldType attribute with the same name.


Copyfield (The contents of this paragraph are copied directly from the SOLR Chinese network):

You may want to make some fields of document available multiple times. SOLR has a field replication mechanism that can submit multiple different types of fields to a field. Field copying mainly involves two concepts, source and destination, one for the field to copy, and the other to which field to copy, here is an example:

1 < Copyfield Source = "cat" dest = "text" Maxchars = "30000"/>

In the example above, if the text field has data, the contents of the Cat field will be added to the text field. The Maxchars parameter, an int type parameter, that restricts the number of characters copied. Both source and destination support wildcard characters. The following is a copy of all fields ending in _t to the text field.

1 < Copyfield Source = "*_t" dest = "text" Maxchars = "25000"/>

In fact, for example, if you want to query the blog containing "Java", then you are sure to check the content, whether the title contains Java, but SOLR cannot be like SQL, where tittle likes '%java% ' or content as '%java% '.  This time Copyfield come in handy, define a new field, copy the title and content to the new field, index, and query directly from this new field, so you can reach the goal. This is the typical application scenario for Copyfield. Note: If Dest is composed of more than one source, it needs to be specified as multivalued. Find an example on the Internet:
<schema name= "eshequn.post.db_post.0" version= "1.1" xmlns:xi= "Http://www.w3.org/2001/XInclude"  
    >  
     <fields>  
        <!--for title---  
        <field name= "T" type= "text" indexed= "true" stored= "false"/>  
        <!--for abstract-  
        <field name= "A" type= "text" indexed= "true" stored= "false"/>  
        <!--for Title and abstract---  
        <field name= "ta" type= "text" indexed= "true" stored= "false" multivalued= "true"/>  
    </fields>  
    <copyfield source= "T" dest= "ta"/>  
    <copyfield source= "a" dest= "ta"/>  
</schema>  




DynamicField: Dynamic fields allows SOLR indexes to have no explicitly defined fields in the schema. This is useful when you forget to define some fields. Dynamic fields can make the system more flexible and more versatile. A dynamic field is similar to a regular field, except that it contains a wildcard character that, when indexed, matches a field in a dynamic field if there is no match in the regular field. Suppose the schema defines a dynamic dynamic field called *_i, if you want to index a field called cost_i, but there is no cost_i field in the schema, so cost_i is indexed into the *_i field. The dynamic field is also defined in the Schema.xml file, and as with other fields, it also has a noun, field type, and attributes.
1 < DynamicField name = "*_i" type = "sint" indexed = "true" stored = "true"/>

It is recommended to define some basic dynamic fields in schema.xml for extension purposes.


Related Article

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.