Skip to content

Instantly share code, notes, and snippets.

@jamieparkinson
Last active September 30, 2020 11:09
Show Gist options
  • Save jamieparkinson/7365939512e54128739b0ed8d33cf90d to your computer and use it in GitHub Desktop.
Save jamieparkinson/7365939512e54128739b0ed8d33cf90d to your computer and use it in GitHub Desktop.
TF-IDF per-field document frequency proof
PUT tf-idf-test
PUT tf-idf-test/_mapping
{
"properties": {
"thing": {
"type": "text"
},
"secret": {
"type": "text"
}
}
}
PUT tf-idf-test/_bulk
{"index":{"_id": "1"}}
{"thing":"Bananas apples lemons oranges cabbages courgettes","secret":"apples apples apples apples apples"}
{"index":{"_id": "2"}}
{"thing":"Bananas lemons oranges courgettes","secret":"apples apples apples apples apples"}
{"index":{"_id": "3"}}
{"thing":"Bananas lemons oranges cabbages courgettes","secret":"apples apples apples apples apples"}
{"index":{"_id": "4"}}
{"thing":"Apples lemons oranges cabbages courgettes","secret":"apples apples apples apples apples"}
{"index":{"_id": "5"}}
{"thing":"Bananas oranges cabbages courgettes","secret":"carrots carrots carrots carrots carrots"}
GET tf-idf-test/_explain/1
{
"query": {
"term": {
"thing": "apples"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment