Reputation: 1003
I have been reading this documentation from elasticsearch: https://www.elastic.co/guide/en/elasticsearch/reference/1.7/analysis-word-delimiter-tokenfilter.html
And at the same was searching the internet for examples. Unfortunately not just there were a few examples most of them doesn't work.
I would really appreciate it if someone can post or give an example on how to use word_delimeter token filter in elasticsearch.
Thanks.
Upvotes: 2
Views: 7953
Reputation: 11
I know this questions is old, but anyways... I cant comment because i dont have reputation points, but if you try to search "everybody" there is no "-" as provided in the above answer,if you want to search "body" in "everybody" maybe a simple wildcard would help you. https://www.elastic.co/guide/en/elasticsearch/reference/6.8/query-dsl-wildcard-query.html
i hope it was usefull
Upvotes: 0
Reputation: 4803
Elasticversion - 5.2
Try the following mappings
PUT demo
{
"settings": {
"analysis": {
"analyzer": {
"index_analyzer_v1" : {
"tokenizer" : "whitespace",
"filter" : [ "word_delimeter"]
}
},
"filter": {
"ngram_filter" : {
"type" : "nGram",
"min_gram": 1,
"max_gram": 10,
"token_chars": [
"letter",
"digit"
]
},
"word_delimeter" : {
"type" : "word_delimiter",
"generate_number_parts" : true,
"catenate_words" : true,
"catenate_numbers": true,
"preserve_original" : true,
"stem_english_possessive": true
},
"stop_words" : {
"type": "stop",
"stopwords": ["and", "is", "the", "we", "in", "are", "was", "were", "of"]
}
}
}
},
"mappings": {
"product": {
"dynamic": "strict",
"properties": {
"name": {
"type": "text",
"analyzer": "index_analyzer_v1"
}
}
}
}
}
Index the following document
POST demo/product
{
"name":"SH-09"
}
Run the following query
POST demo/_search
{
"query": {"bool": {"must": [
{"term": {
"name": {
"value": "09"
}
}}
]}}
}
Furthur more if you want to see the values stored in inverted index, run the following query
GET demo/_analyze?analyzer=index_analyzer_v1&text=SH-09
Hope this helps
Upvotes: 3