Hi, I have a use case where I want to search using wild-cards on a custom
analyzed field. I am currently seeing some discrepancies w.r.t what I
expect.
Basically, I have string data in a field, such as "Name-55", "Name-56" etc.
I want to be able to search for "Name-5*", and get these results.
I have indexed the data into these terms
"Name", "-", "55"
"Name", "-", "56"
using a custom pattern analyzer to achieve this. I am using a similar
custom pattern analyzer for my query string, except that I am swallowing
any whitespaces, &,? and *.
"my_template" : {
"template" : "",
"order": 1,
"settings" :{
"analysis": {
"analyzer": {
"custom_index":{
"type": "pattern",
"pattern":"([\s]+)|((?<=\p{L})(?=\P{L})|((?<=\P{L})(?=\p{L}))|((?<=\d)(?=\D))|((?<=\D)(?=\d)))"
},
"custom_search":{
"type": "pattern",
"pattern":"([?&\s]+)|((?<=\p{L})(?=\P{L})|((?<=\P{L})(?=\p{L}))|((?<=\d)(?=\D))|((?<=\D)(?=\d)))"
}
}
}
},
"mappings" : {
"account" : {
"properties" : {
"myfield" : {
"type" : "string",
"store" : "yes",
"index" : "analyzed",
"index_analyzer" :"custom_index",
"search_analyzer":"custom_search"
}}}}}}
Using this, I see that when I search for "Name-5*", I do not get any
results returned.
However, if I search for "Name- 5*" (Note additional white-space in the
search string), then I get the results Name-55 and Name-56.
Do you have an understanding of why elasticsearch may be exhibiting this
behavior? Is there some issue in the way I have setup the patterns in my
analyzer?
Your help is much appreciated, Thanks!
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c0a3f237-ea6a-43a7-aefb-c22eb61c75f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.