Created
July 8, 2017 06:12
-
-
Save yanglikun/559e3020cc4ef8248c2f4658fcfa1c72 to your computer and use it in GitHub Desktop.
es index option和搜索的关系
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
index选项相对_all字段:
no :不会加入_all字段,不能被搜索
not_analyzed:会加入_all字段,加入_all字段的值是经过分析的
https://www.elastic.co/guide/en/elasticsearch/reference/2.1/include-in-all.html