SOLR 6.1 Study Notes (i)--configuration file Managed-schema (Schema.xml) (2)

Source: Internet
Author: User
Tags solr

Pick up the article

2. <dynamicField>

Provides a uniform definition of some fields that satisfy a prefix or suffix. For example, <dynamicfield name= "*_s" index= "true" stored= "true" type= "string"/> means all field with "_s" suffix has index= "true" stored= "True" type= "string" for these properties. DynamicField are typically used in the following situations:

The 2.1 document model has more fields

For a chestnut: to index a PDF file, SOLR provides a simple RequestHandler-/update/extract, which eventually calls Apache's other open source project Tika to parse the PDF file. The parsed document returned by SOLR contains a lot of field, we just want some of these field, if we only configure the field we want in <field>, then the index will be an error, The error message is generally not defined what field, at this time, we can configure a <dynamicfield name= "ignore_*" type= "ignored" multivalued= "true"; Then in the corresponding RequestHandler in the Solrconfig.xml configuration <str name= "Uprefix" >IGNORE_</STR> This will be ignored for field that is not defined in Managed-schema.

2.2 support for documents from different sources

For example, when you want to add a field that labels its source, you can configure the following:

<field name= "Source1_field1" type= "string" index= "true" stored= "true"/>

<field name= "Source1_field2" type= "string" index= "true" stored= "true"/>

<field name= "source1_field3" type= "string" index= "true" stored= "true"/>

...

<field name= "Source2_field1" type= "string" index= "true" stored= "true"/>

<field name= "Source2_field2" type= "string" index= "true" stored= "true"/>

<field name= "source2_field3" type= "string" index= "true" stored= "true"/>

But if there are many sources, this configuration is too much. We only need to configure <dynamicfield name= "*_s" index= "true" stored= "true" type= "string"/>, and then the index is changed to:

<doc>

<field name= "id" >hello</field>

<field name= "source1_field1_s" >hello</field>

</doc>

In this way, the field name at the time of the index preserves the source information and does not require many field definitions to be configured in the configuration file.

2.3 Add a new document source

As the above example, if there is a new source of documentation in the future, we may not have to add such <field name= "Source5_field1" type= "string" index= "true" stored= "true"/> in the configuration file With this configuration, you can add fields such as "source5_field1_s" directly to the index.

3. <uniqueKey>

In general, you need to configure <UNIQUEKEY>ID</UNIQUEKEY>, although the directory is not required, it is strongly recommended to set this value. It's like a database design, although you don't force each table to have a primary key, you typically set a primary key.

4. <copyField>

When using Baidu or Google search, we may want to search for a person name, or the title, or the name of the site, and its background index file by the different field to save those values, then it is how to use an input box to search the content of different field? The answer is <copyField> (do not know what Baidu or Google search technology, but the principle should be similar)

<field name= "Text" type= "string" index= "true" stored= "true" multivalues= "true"/>

<copyfield source= "Man_name" dest= "text"/>

<copyfield source= "Book_name" dest= "text"/>

<copyfield source= "web_address" dest= "text"/>

So we just have to search the text for the content.

SOLR 6.1 Study Notes (i)--configuration file Managed-schema (Schema.xml) (2)

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.