Hi,
If i create an alias with a hyphen in it (ie. a-b), elastic search does not find any documents.
Is there a workaround?
http://example.com/a-b/
_search GET
{
"query": {
"queryString": {
"query": "something"
}
}
}
Hi,
If i create an alias with a hyphen in it (ie. a-b), elastic search does not find any documents.
Is there a workaround?
http://example.com/a-b/
_search GET
{
"query": {
"queryString": {
"query": "something"
}
}
}
Can you please provide a full script replicating the issue?
Ok, let me try (Most of the work is done by wrapper libraries):
http://example.com/master
_alias/a-b PUT
{
"routing": "a-b",
"filter": {
"term": {
"domain.name": "a-b"
}
}
}
Add any document with (domain.name="a-b"
Try to search:
{
"query": {
"queryString": {
"query": "something"
}
}
}
Aha! When I write it this way; Might it be because of:
"filter": {
"term": {
"domain.name": "a-b"
}
}
If you are using a default analyzer for your field, this won't work.
What is your mapping?
{
"_default_" :
{
"date_detection" : false,
"properties" :
{
"@timestamp" :{ "type" : "date", "format" : "dateOptionalTime" },
"domain": {
"properties": {
"_hibernate_class": {
"type": "string"
},
"name": {
"type": "string"
},
"id": {
"type": "long"
}
}
}
}
}
}
and,
analysis:
analyzer:
default:
type: custom
tokenizer: standard
filter: [filename_word_delimiter, standard, lowercase, asciifolding]
filename_analyzer:
type: custom
tokenizer: lowercase
filter: [filename_word_delimiter, filename_ngram]
filter:
filename_ngram:
type: nGram
min_gram: 3
max_gram: 10
filename_word_delimiter:
type: word_delimiter
generate_word_parts: true
catenate_words: true
catenate_numbers: true
catenate_all: true
split_on_case_change: false
preserve_original: true
split_on_numerics: false
stem_english_possessive: true
domain.name uses the default analyzer which lowercase, breaks your string into tokens...
You need to change its mapping and set index: not_analyzed.
Unfortunately it did not work.
I changed the mapping to:
{
"_default_" :
{
"date_detection" : false,
"properties" :
{
"@timestamp" :{ "type" : "date", "format" : "dateOptionalTime" },
"domain": {
"properties": {
"_hibernate_class": {
"type": "string"
},
"name": {
"type": "string",
"index": "not_analyzed"
},
"id": {
"type": "long"
}
}
}
}
}
}
Restarted elastic-search,
Created another alias with hyphen,
Added a document and searched.
Finds the alias, does not find any document.
But thanks anyway, it is not an alias problem but a search problem. I can find a way to fix it.
Yeah. You have to create a new index and reindex.
Look at the actual mapping for the index you already have.
My guess is that it's still analyzed.
Yes! Reindex worked. Many thanks! 
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.