Hello everybody.
I was wondering if it is possible to have within a variable in NodeJs two types of filters, for example:
query = {
"bool": {
"must": [
{
"multi_match" : {
"query": strQuery + "~",
"fields": ["strDescription^10", "strCategory^30", "strSubCategory^40"],
"type": "best_fields",
"operator": "or",
"fuzziness": "auto"
},
},
// In this part I want to add a filter for synonyms.
{
"bool":{
"should":[
{
range: {
"intExistenceOmicron" : {
gt:0
}
}
},
{
range: {
"intExistence" : {
gt:0
}
}
}
]
}
}
],
"must_not": {
"term": {
"strImage": ""
}
},
"minimum_should_match" : "50%"
}
};
I developed the filter for synonyms as follows:
query = {
"bool": {
"must": [
{
"multi_match": {
"query": strQuery + "~",
"fields": ["strDescription^10", "strCategory^30", "strSubCategory^40", "strVendorPart"],
"minimum_should_match": "95%",
"analyzer" : "elastic_synonym_analyzer"
},
},
{
"bool": {
"should": [
{
range: {
"intExistenceOmicron":
{
gt: 0
}
}
},
{
range: {
"intExistence":
{
gt: 0
}
}
}
]
}
}
],
"must_not": {
"term": {
"strImage": ""
}
},
"minimum_should_match": "95%"
}
};
What I want to achieve is that I do the search first using synonyms, if you do not find any synonyms use the type filter: "best_fields"
Thank you very much for the help