Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Field, CopyField and DynamicField

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to use Field, CopyField and DynamicField". In daily operation, I believe many people have doubts about how to use Field, CopyField and DynamicField. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use Field, CopyField and DynamicField". Next, please follow the editor to study!

Field:

Field is a field. It is easy to define a Field:

Basically, the attribute is similar to FieldType, where its attribute overrides the FieldType attribute of the same name.

CopyField (this paragraph is directly from the solr Chinese website copy):

You may want some fields in document to be used multiple times. Solr has a field replication mechanism that allows you to submit multiple different types of fields into one field. Field replication mainly involves two concepts, source and destination, one is the field to be copied, and the other is which field to copy to. Here is an example:

one

In the above example, 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, is used to limit the number of characters copied.

Both source and destination support wildcards. The following is a copy of all fields ending in _ t into the text field.

one

In fact, to put it simply, for example, if you want to query a blog that contains "Java", you must check the content and whether the title contains Java, but solr cannot be like SQL, where tittle like'% Java%' or content like'% Java%'. At this point, copyField comes in handy, defining a new field, copying title and content to the new field, and querying directly from the new field when indexing, so that the target is reached. This is a typical application scenario for copyField. Note: if the dest consists of multiple source, you need to specify it as multiValued.

I found an example on the Internet:

DynamicField:

Dynamic fields (Dynamic fields) allow solr indexes to have fields that are not explicitly defined in schema. This is useful when you forget to define some fields. Dynamic fields can make the system more flexible and versatile.

A dynamic field is similar to a regular field, except that it contains a wildcard in its name, when indexing a document, if a field does not match in the regular field, it will match in the dynamic field.

Suppose a dynamic field called * _ I is defined in schema. If you want to index a field called cost_i, but there is no cost_i field in schema, then cost_i will be indexed into the * _ I field.

Dynamic fields are also defined in the schema.xml file, and like other fields, they have a noun, field type, and attribute.

one

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

At this point, the study on "how to use Field, CopyField and DynamicField" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report