Explicit Mapping and set common parameters introduced

Original: Explicit Mapping and set common parameters introduced

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/wnn1029/article/details/100750255

Custom Mapping of some of the recommendations

  • In order to reduce the workload of inputs, reducing the probability of error, you can follow the steps
    • Create a temporary index, write some sample data
    • The temporary file obtained by accessing Mapping API o Dynamic Mapping definitions
    • After modification by using this configuration creates your index
    • Delete temporary index

Control whether the current field is indexed

  • index - control whether the current field is indexed, the default is true, if set to false, this field can not be indexed

Index Options

  • Four different levels of Index Options configuration, you can control the inverted index recorded content
    • docs - Record doc id
    • freqs - Record doc id and term frequencies
    • positions - 记录doc id/term frequencies / term position
    • offsets - doc id / term frequencies / term position / character offects
  • Text Type Default record positions, other default docs
  • The more recorded content, the greater take up storage space

null_value

  • We need to implement a search for null values, as long as the keyword type supports setting null_value
PUT users
{
	"mappings" : {
		"properties":{
			"mobile":{
				"type":"keyword",
				"null_value":"NULL"
			}
		}
	}
}

   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

copy_to settings

  • _all 7 are replaced copy_to
  • To meet the specific needs of search
  • copy_to numeric field is copied into the target field, to achieve a similar effect of _all
  • copy_to field goal does not appear in _source
PUT users
{
	"mappings" : {
		"properties":{
			"firstName":{
				"type":"keyword",
				"copy_to":"fullName"
			}
		}
	}
}

   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

Array type

  • Elasticsearch not provide specialized array type, but any field can contain a plurality of values ​​of the same type

Multi-field type

  • Multi-field characteristics
    • Using different analyzer
      • Different languages
      • Pinyin search field
      • Support to specify a different analyzer for the search and indexing
PUT products
{
	"mappings" : {
		"properties":{
			"comment":{
				"type":"keyword",
				"fields":{
					"english_comment":{
						"type":"text",
						"analyzer":"english",
						"search_analyzer":"english"
					}
				}
			}
		}
	}
}

   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • Index Template: helps you to set Mapping and Settings, and according to certain rules, to automatically match the newly created index above
  • And Dynamic Template

Guess you like

Origin www.cnblogs.com/lonelyxmas/p/11614554.html