Solr basic use

1,schema.xml:

schema.xml is in SolrCore's conf directory, mainly used to configure the use of domain names and domain types (domain names must be defined before use)

1.1, the domain of solr: Field

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />

name: domain name

type: the type of the domain (also needs to be configured)

indexed: whether to index true index false not to index

stored: whether to store

required: whether it is required, generally only the id is required

multiValued: Whether multivalued can be multi-valued When true, the value in it is stored in data format. For example, the uploaded image will have three versions, large, medium and small.

 

1.2, Solr's dynamic field configuration: dynamicField

<dynamicField name="*_i"  type="int"    indexed="true"  stored="true"/>

name: Specifies the name of the domain. The domain name is determined by the domain expression.

type: the type of the field. When using a dynamic field, you need to determine the type of the field

 

1.3, Solr's primary key field uniqueKey

There should be a unique primary key in every document

<uniqueKey>id</uniqueKey>

 

1.4, solr's replication domain

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

source: original domain

dest: target domain

原域:<field name="cat" type="string" indexed="true" stored="true" multiValued="true"/>

目标域:<field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>

The target field must be: multiValued:true

 

1.5, the type of solr's domain fieldType

 

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
	<tokenizer class="solr.StandardTokenizerFactory"/>
	<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
	<!-- in this example, we will only use synonyms at query time
	<filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
	-->
	<filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
  <analyzer type="query">
	<tokenizer class="solr.StandardTokenizerFactory"/>
	<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
	<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
	<filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>

name: the name of the type of the domain

class: specifies the type of solr

analyzer: configure the tokenizer

type:index (index tokenizer) query (query tokenizer)

tokenizer: tokenizer

filter: filter

 

 2, configure the Chinese tokenizer:

Just use ikAnalyzer

2.1, copy the jar package

 

2.2, copy the configuration file

 

2.3, the type of configuration domain

 

2.4, configure the domain

 

2.5, restart tomcat test

 

3, the configuration of the business domain name

3.1,

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327003005&siteId=291194637