{
"query": {
"match_all": {}
}
}
分词器
测试ik切词:http://host_name_xx:port_yyy/qa_pair/_analyze?analyzer=ik&pretty=true&text=我是中国人"
综上,同样是对“这是一个对分词器的测试”进行分词,不同的分词器分词结果不同:
ik_max_word:这是/一个/一/个/对分/分词器/分词/词/器/测试
ik_smart:这是/一个/分词器/测试
standard:这/是/一/个/对/分/词/器/的/测/试
{"analyzer":"ik_max_word","text":"这是一个分词器"}
/person/_mapping
index
属性控制怎样索引字符串。它可以是下面三个值:
analyzed
首先分析字符串,然后索引它。换句话说,以全文索引这个域。
not_analyzed
索引这个域,所以它能够被搜索,但索引的是精确值。不会对它进行分析。
no
不索引这个域。这个域不会被搜索到。
string
域 index
属性默认是 analyzed
。如果我们想映射这个字段为一个精确值,我们需要设置它为 not_analyzed
:
{
"tag": {
"type": "string",
"index": "not_analyzed"
}
}
虽然写入数据时Elasticsearch会自动的添加映射进行处理,但是删除数据并不会删除数据的映射
#curl -XDELETE 'http://localhost:9200/logstash-2016.01.01/syslog' 删除了syslog下面的全部数据,但是syslog的映射还在
删除映射的命令:
#curl -XDELETE 'http://localhost:9200/logstash-2016.01.01/_mapping'
删除索引的话映射也会删除
#curl -XDELETE 'http://localhost:9200/logstash-2016.01.01'
{
"query": {
"bool": {
"must": [
{
"range": {
"id": {
"gt": "223819210319466490",
"lt": "223819210319466499"
}
}
}
,
{
"range": {
"birthday": {
"gt": "8551-01-12T01:01:00",
"lt": "8552-01-12T01:01:01Z"
}
}
}
,
{
"term": {
"married": "false"
}
}
],
"must_not": [ ],
"should": [ ]
}
},
"from": 0,
"size": 10,
"sort": [ ],
"aggs": { }
}
{
- "query": {
- "bool": {
- "must": [
- {
- "range": {
- "id": {
- "gt": "223819210319466490",
- "lt": "223819210319466499"
- "id": {
- "range": {
- ,
- {
- "range": {
- "birthday": {
- "gt": "8551-01-12T01:01:00",
- "lt": "8552-01-12T01:01:01Z"
- "birthday": {
- "range": {
- ,
- {
- "term": {
- "married": "false"
- "term": {
- ,
- {
- "query_string": {
- "default_field": "profile.keyword",
- "query": "政治"
- "query_string": {
- {
- "must_not": [ ],
- "should": [ ]
- "must": [
- "bool": {
- "from": 0,
- "size": 10,
- "sort": [ ],
- "aggs": { }
}
{
"settings": {
"number_of_shards": 5,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"ik": {
"tokenizer": "ik_max_word"
}
}
}
},
"mappings": {
"person": {
"properties": {
"birthday": {
"type": "date"
},
"score": {
"type": "double"
},
"profile": {
"type": "text",
"analyzer": "ik",
"search_analyzer": "ik_max_word"
},
"name": {
"type": "string",
"index": "not_analyzed"
},
"id": {
"type": "long"
},
"married": {
"type": "boolean"
},
"age": {
"type": "long"
},
"@timestamp": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
}
}
}
}
}
{
"query": {
"match_phrase": {
"profile": "政治"
}
},
"highlight": {
"pre_tags": [
"<font size=\"5\" face=\"arial\" color=\"red\">"
],
"post_tags": [
"</font>"
],
"fields": {
"profile": {}
}
}
}
{
"query": {
"match_phrase": {
"content": "因为去年我碰到了跟踪狂"
}
},
"highlight": {
"pre_tags": [
"<font size=\"5\" face=\"arial\" color=\"red\">"
],
"post_tags": [
"</font>"
],
"fields": {
"content": {}
}
}
}
{
"query": {
"match_phrase": {
"content": "因为去年我碰到了跟踪狂"
}
}
}
{
"query": {
"bool": {
"must": [
{
"match": {
"content": "曹操败军上溯长江而逃,本欲回归江陵"
}
}
]
}
}
}
{
"query": {
"bool": {
"must": [
{
"match": {
"content": "曹操败军上溯长江而逃,本欲回归江陵"
}
}
]
}
},
"highlight": {
"pre_tags": [
"<font size=\"5\" face=\"arial\" color=\"red\">"
],
"post_tags": [
"</font>"
],
"fields": {
"content": {}
}
}
}
{
"query": {
"bool": {
"must": [
{
"match": {
"content": "小李飞刀 霸王别姬"
}
}
]
}
},
"highlight": {
"pre_tags": [
"<em>"
],
"post_tags": [
"</em>"
],
"fields": {
"content": {}
}
}
}
{
"query": {
"bool": {
"must": [
{
"match": {
"content": "曹操败军上溯长江而逃,本欲回归江陵"
}
}
]
}
},
"highlight": {
"pre_tags": [
"<em>"
],
"post_tags": [
"</em>"
],
"fields": {
"content": {}
}
}
}
bookresource
{
"settings": {
"number_of_shards": 5,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"ik": {
"tokenizer": "ik_max_word"
}
}
}
},
"mappings": {
"person": {
"properties": {
"bookid": {
"type": "long"
},
"rid": {
"type": "string",
"index": "not_analyzed"
},
"title": {
"type": "text",
"analyzer": "ik",
"search_analyzer": "ik_max_word"
},
"originalHref": {
"type": "string",
"index": "not_analyzed"
},
"content": {
"type": "text",
"analyzer": "ik",
"search_analyzer": "ik_max_word"
}
}
}
}
}