标签:
mapping
curl -XPUT ‘localhost:9200/hl-test‘ -d ‘{
"settings": {
"index": {
"number_of_shards": 2,
"number_of_replicas": 0
}
},
"mappings": {
"tm": {
"properties": {
"content1": {
"type": "string",
"analyzer" : "default",
"store": "yes",
"term_vector" : "with_positions_offsets"
},
"content2": {
"type": "string",
"analyzer" : "default",
"store": "yes",
"index_options" : "offsets"
},
"content3": {
"type": "string",
"store": "yes",
"analyzer" : "default"
},
"content4": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
}
}
}
}
}‘
note
offsets
Store docs, freqs, positions, and the start and end character offsets of each term in the original string. This information is used by the postings >highlighter but is disabled by default.
来源: https://www.elastic.co/guide/en/elasticsearch/guide/current/stopwords-phrases.html#index-options
测试数据curl -XPUT ‘http://localhost:9200/hl-test/tm/1‘ -d ‘{
"content1": "In the above case, the content field will be highlighted for each search hit (there will be another element in each search hit, called highlight, which includes the highlighted fields and the highlighted fragments)."
}‘
{
"query": {
"term": {
"content1": "the"
}
},
"highlight": {
"pre_tags": [
"<tag1>"
],
"post_tags": [
"</tag1>"
],
"fields": {
"content1": {
"type": "fvh",
"fragment_size": 30,
"number_of_fragments": 1,
"force_source": true,
"order": "score",
"fragment_offset": 3,
"no_match_size": 2
},
"content2": {
"fragment_size": 250,
"number_of_fragments": 0
},
"content3": {
"fragment_size": 250,
"number_of_fragments": 3,
"force_source": true
}
}
}
}
标签:
原文地址:http://www.cnblogs.com/jasonbrooke/p/4645049.html