Skip to content

Instantly share code, notes, and snippets.

@yanglikun
Created July 8, 2017 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanglikun/559e3020cc4ef8248c2f4658fcfa1c72 to your computer and use it in GitHub Desktop.
Save yanglikun/559e3020cc4ef8248c2f4658fcfa1c72 to your computer and use it in GitHub Desktop.
es index option和搜索的关系
DELETE index_option_demo_index
PUT /index_option_demo_index
PUT /index_option_demo_index/_mapping/index_option_type
{
"index_option_type": {
"_all": {
"enabled": false
},
"properties": {
"analyzedDesc": {
"type": "string",
"index": "analyzed"
},
"notAnalyzedDesc": {
"type": "string",
"index": "not_analyzed"
},
"noAnalyzedDesc": {
"type": "string",
"index": "no"
}
}
}
}
GET index_option_demo_index/index_option_type/_mapping
PUT /index_option_demo_index/index_option_type/1
{
"analyzedDesc":"core java"
}
PUT /index_option_demo_index/index_option_type/2
{
"notAnalyzedDesc":"core java"
}
PUT /index_option_demo_index/index_option_type/3
{
"noAnalyzedDesc":"core java"
}
#query all
GET /index_option_demo_index/_search
{
"query": {
"match_all": {}
}
}
#query on all
GET /index_option_demo_index/_search
{
"query":{
"match": {
"_all": "core"
}
}
}
##query on field
#analyzed
GET /index_option_demo_index/_search
{
"query": {
"match": {
"analyzedDesc": "java"
}
}
}
#notAnalyzed
GET /index_option_demo_index/_search
{
"query": {
"match": {
"notAnalyzedDesc": "core java"
}
}
}
#noAnalyzed
GET /index_option_demo_index/_search
{
"query": {
"match": {
"noAnalyzedDesc": "java"
}
}
}
GET /index_option_demo_index/index_option_type/2/_termvectors
{
"fields" : ["notAnalyzedDesc"],
"offsets" : true,
"payloads" : true,
"positions" : true,
"term_statistics" : true,
"field_statistics" : true
}
@yanglikun
Copy link
Author

yanglikun commented Jul 8, 2017

index选项相对_all字段:
no :不会加入_all字段,不能被搜索
not_analyzed:会加入_all字段,加入_all字段的值是经过分析的
https://www.elastic.co/guide/en/elasticsearch/reference/2.1/include-in-all.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment