Skip to content

Instantly share code, notes, and snippets.

@jprante
Last active April 13, 2023 06:55
Show Gist options
  • Save jprante/cd120eac542ba6eec965 to your computer and use it in GitHub Desktop.
Save jprante/cd120eac542ba6eec965 to your computer and use it in GitHub Desktop.
Hyphen Tokenizer Demo
DELETE /test
PUT /test
{
"index" : {
"analysis" : {
"analyzer" : {
"default" : {
"type" : "custom",
"tokenizer" : "hyphen",
"filter" : [
"lowercase",
"icu_normalizer",
"icu_folding",
"hyphen"
]
}
}
}
}
}
PUT /test/test/1
{
"content" : "Versorgungstechnik-Tage"
}
PUT /test/test/2
{
"content" : "Versorgungstechniktage"
}
PUT /test/test/3
{
"content" : "Versorgungstechnik"
}
POST /test/_search
{
"query" : {
"simple_query_string" : {
"query" : "versorgungstechnik-tage",
"default_operator": "and",
"fields" : [ "content" ]
}
},
"aggregations" : {
"agg1" : {
"terms" : {
"field" : "content"
}
}
}
}
{
"took": 48,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 0.61370564,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": "1",
"_score": 0.61370564,
"_source": {
"content": "Versorgungstechnik-Tage"
}
},
{
"_index": "test",
"_type": "test",
"_id": "2",
"_score": 0.053528976,
"_source": {
"content": "Versorgungstechniktage"
}
},
{
"_index": "test",
"_type": "test",
"_id": "3",
"_score": 0.053528976,
"_source": {
"content": "Versorgungstechnik"
}
}
]
},
"aggregations": {
"agg1": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "versorgungstechnik",
"doc_count": 2
},
{
"key": "versorgungstechniktage",
"doc_count": 2
},
{
"key": "tage",
"doc_count": 1
},
{
"key": "versorgungstechnik-tage",
"doc_count": 1
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment