Skip to content

Instantly share code, notes, and snippets.

@roytmana
Last active December 27, 2015 13:49
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 roytmana/7336502 to your computer and use it in GitHub Desktop.
Save roytmana/7336502 to your computer and use it in GitHub Desktop.
test postings highlighter
curl -XDELETE http://localhost:9200/test
curl -XPOST "http://localhost:9200/test/ht/" -d'{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"filter": {
"stem_possessive_english": {
"type": "stemmer",
"name": "possessive_english"
},
"stem_deduplicate": {
"type": "unique",
"only_on_same_position": true
}
},
"analyzer": {
"stemmed": {
"tokenizer": "standard",
"filter": [
"standard",
"lowercase",
"stop",
"stem_possessive_english",
"keyword_repeat",
"kstem",
"stem_deduplicate"
]
},
"stemmed_no_original": {
"tokenizer": "standard",
"filter": [
"standard",
"lowercase",
"stop",
"stem_possessive_english",
"kstem"
]
},
"not_stemmed": {
"tokenizer": "standard",
"filter": [
"standard",
"lowercase",
"stop",
"stem_possessive_english"
]
}
}
}
},
"mappings": {
"ht": {
"properties": {
"key": {
"type": "string",
"index_options": "offsets",
"boost": 1
},
"name": {
"type": "multi_field",
"path": "just_name",
"fields": {
"name": {
"type": "string",
"index_options": "offsets",
"boost": 10,
"analyzer": "stemmed"
},
"all": {
"type": "string",
"index_options": "offsets",
"boost": 10,
"analyzer": "stemmed"
}
}
},
"junk": {
"type": "multi_field",
"path": "just_name",
"fields": {
"junk": {
"type": "string",
"index_options": "offsets",
"boost": 0.1,
"analyzer": "stemmed"
},
"all": {
"type": "string",
"index_options": "offsets",
"boost": 0.1,
"analyzer": "stemmed"
}
}
}
}
}
}
}'
curl -XPOST "http://localhost:9200/test/ht/" -d'
{"key":"Active wards", "name":"complete all testing and bug remediation activities", "junk":"testing must be performed today and all tests completed"}'
curl -XPOST "http://localhost:9200/test/ht/" -d'
{"key":"Active Awards", "name":"Complete All Testing and Bug Remediation Activities", "junk":"testing must be performed today and all active tests completed"}'
curl -XPOST "http://localhost:9200/test/ht/_search/" -d'
{
"query": {
"match": {
"all": {
"query": "test",
"type": "phrase",
"analyzer": "stemmed"
}
}
},
"highlight": {
"fields": {
"key":{"type":"postings"},
"name":{"type":"postings"},
"junk":{"type":"postings"}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment