Skip to content

Instantly share code, notes, and snippets.

@edwardsmit
Last active September 23, 2015 13:32
Show Gist options
  • Save edwardsmit/2ec8506db2e4402024dd to your computer and use it in GitHub Desktop.
Save edwardsmit/2ec8506db2e4402024dd to your computer and use it in GitHub Desktop.
Elasticsearch: no_match_size not obeyed using the fvh
#!/usr/bin/env bash
curl -XDELETE 'localhost:9200/highlightproblem'; echo
curl -XPUT 'localhost:9200/highlightproblem'; echo
curl -XPUT 'localhost:9200/highlightproblem/highlightproblem/_mapping' -d '{
"highlightproblem": {
"properties": {
"title": {
"type": "string",
"term_vector": "with_positions_offsets"
},
"body": {
"type": "string",
"term_vector": "with_positions_offsets"
}
}
}
}'; echo
curl -XPUT 'localhost:9200/highlightproblem/highlightproblem/1' -d '{
"title": "Highlight title",
"body": "Highlight singular body"
}'; echo
curl -XPUT 'localhost:9200/highlightproblem/highlightproblem/2' -d '{
"title": "Highlight title",
"body": ["array body", "array body 2"]
}'; echo
curl -XPUT 'localhost:9200/highlightproblem/highlightproblem/3' -d '{
"title": "Highlight title",
"body": "Singular body"
}'; echo
curl -XPUT 'localhost:9200/highlightproblem/highlightproblem/4' -d '{
"title": "Highlight title",
"body": ["highlight array body", "array body 2"]
}'; echo
curl -XPOST 'http://localhost:9200/highlightproblem/_refresh'; echo
curl -XPOST 'http://localhost:9200/highlightproblem/_search?pretty' -d '{
"query": {
"match": {
"_all": "highlight"
}
},
"highlight": {
"fields": {
"body": {
"fragment_size": 100,
"number_of_fragments": 2,
"no_match_size": 100
}
}
}
}'
echo "Observe the missing highlight-field containing the no_match contents for #id 2"
@edwardsmit
Copy link
Author

Updated based on feedback in elastic/elasticsearch#13734

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