I have created the following index settings and mapping . I used the simple query string syntax for search .
Do I need to explicitly specify my custom analyzer in the simple query search or it uses the required analyzer based on the mapping .
{
"settings": {
"analysis": {
"analyzer": {
"generic_description_analyzer": {
"type": "custom",
"tokenizer": "icu_tokenizer",
"filter": [
"b_synonym",
"lowercase",
"word_split",
"icu_folding",
"english_stop",
"char_replace"
]
}
},
"filter": {
"english_stop": {
"type": "stop",
"stopwords": "english"
},
"word_split": {
"type": "word_delimiter",
"preserve_original": 1
},
"char_replace": {
"type": "pattern_replace",
"pattern": "'",
"replacement": ""
},
"b_synonym": {
"type": "synonym",
"ignore_case": true,
"synonyms_path": "analysis/brand_synonym.txt"
}
}
}
},
"mappings": {
"brands": {
"properties": {
"brand": {
"type": "text",
"analyzer": "generic_description_analyzer"
},
"localbrand": {
"type": "text",
"analyzer": "generic_description_analyzer"
},
"globalbrandextension": {
"type": "text",
"analyzer": "generic_description_analyzer"
},
"productidentifier": {
"type": "text",
"analyzer": "generic_description_analyzer"
},
"category": {
"type": "text",
"analyzer": "generic_description_analyzer"
}
}
}
}
}
Query 1:
{
"query": {
"simple_query_string" : {
"query": "+(|Foster's|Foster's Lager|Foster's Lager Beer)+",
"fields": ["brand", "globalbrandextension", "localbrand", "productidentifier"],
"default_operator": "OR"
}
}
}
Query 2
{
"query": {
"simple_query_string" : {
"query": "+(|Foster's|Foster's Lager|Foster's Lager Beer)+",
"fields": ["brand", "globalbrandextension", "localbrand", "productidentifier"],
"default_operator": "OR",
"analyzer": "generic_description_analyzer"
}
}
}
Which query is correct ?
Also how do I run analyze for the simple query string ?
I tried this Is this correct way of analyzing ? I want to see all the tokens.
GET /indexname/_analyze
{
"field": "brand",
"explain": true,
"text": ["|Foster's|Foster's Lager|Foster's Lager Beer"]
}