I am creating an index using as a search analyzer, an alayzer that has a synonym filter. The query that creates the index is the following:
{
"settings": {
"index": {
"analysis": {
"filter": {
"synonym": {
"type": "synonym_graph",
"synonyms_path": "analysis/dpp_codici_ipertestuali.txt",
"updateable": true
},
"italian_stemmer": {
"type": "stemmer",
"language": "light_italian"
},
"italian_stop": {
"ignore_case": "true",
"type": "stop",
"stopwords": "_italian_"
},
"italian_elision": {
"type": "elision",
"articles": [
"c",
"l",
"all",
"dall",
"dell",
"nell",
"sull",
"coll",
"pell",
"gl",
"agl",
"dagl",
"degl",
"negl",
"sugl",
"un",
"m",
"t",
"s",
"v",
"d"
],
"articles_case": true
}
},
"analyzer": {
"dpp_italian": {
"filter": [
"italian_elision",
"lowercase",
"italian_stop",
"italian_stemmer"
],
"char_filter": [
"html_strip"
],
"tokenizer": "standard"
},
"dpp_italian_synonym": {
"filter": [
"lowercase",
"synonym"
],
"char_filter": [
"html_strip"
],
"tokenizer": "standard"
}
},
"tokenizer": {
"custom_hierarchy": {
"type": "path_hierarchy",
"delimiter": "."
}
}
}
}
},
"mappings": {
"properties": {
"testo": {
"type": "text",
"fields": {
"italian": {
"type": "text",
"analyzer": "dpp_italian",
"search_analyzer": "dpp_italian"
},
"italian_synonym": {
"type": "text",
"analyzer": "dpp_italian",
"search_analyzer": "dpp_italian_synonym"
}
}
}
}
}
}
I am trying to do a simple match query over a small amount of test data, but using the filed which uses the synonym analyzer is returning 0 results even if the document exsists. This is the query:
{
"query": {
"match": {
"testo.italian_synonym": {
"query": "Codice di Procedura Civile art. 2",
"operator": "and"
}
}
}
}
If i use the "testo.italian" field, the document is returned.
Can somebody please help me understand why the synonyms are creating an issue when it comes to operator "and"? (in "or" everything works) Thank you!