field, Copyfield, DynamicField in SOLR

Source: Internet
Author: User
Tags solr

Field:

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

XML code
    1. <span style="font-size:20px;" ><field name="tile" type="string" indexed="true" stored=" True "/></span>

Field properties are similar to FieldType, whose properties override FieldType's same name attribute.

Copyfield

You may want to make some fields of document available multiple times. SOLR has a field replication mechanism that can submit several different types of fields to a field, such as copying the title field and the Content field into a new field, so that the new field has the contents of both fields. 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:

<copyField source="cat" dest="text" maxChars="30000" />

In the above example, if the Cat 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.

<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.

XML code
  1. <schema name= "eshequn.post.db_post.0" version="1.1 "
  2. xmlns:xi="Http://www.w3.org/2001/XInclude">
  3. <fields>
  4. <!--for title --
  5. <field name="T" type="text" indexed="true" stored="false" />
  6. <!--for abstract --
  7. <field name="a" type="text" indexed="true" stored="false" />
  8. <!--for title and abstract --
  9. <field name="ta" type="text" indexed="true" stored="false" multivalued="true"/>
  10. </fields>
  11. <Copyfield source="T" dest="ta" />
  12. <Copyfield source="a" dest="ta" />
  13. </schema>

DynamicField: Dynamic fields allows SOLR to index fields that are not explicitly defined in the schema. This feature 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. Dynamic fields are also defined in the Schema.xml file, as are other fields, which also have nouns, field types, and properties.

"Source Address acquisition

SPRINGMVC + mybatis Integration details, and the problems encountered, please refer to the following information:

Resources:

Http://www.springmvc,net/detail/6074493.html

http://my.spring.net/wangbiglei/blog/489583

http://my.springmvc.net/wangbiglei/blog/489604

field, Copyfield, DynamicField in SOLR

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.