elasticsuite
elasticsuite copied to clipboard
allow exact match for strings
Sometimes you are in need to make an exact match instead of like in strings. For example I have a string with values "5", "50". With like I have no possibility to get only the value "5".
Hi @mvenghaus
what's the output of this in the rule form ?
german .. but i think you get it ;)
Hello @mvenghaus,
Adding the operator is not enough though, one also needs to implement the specific query that must be generated to perform the "IS" operation which is to be intended as "contains this ... AND ONLY THIS". Otherwise, you will have the exact same "match" query generated by those lines.
The initial idea is probably to perform a "term" query. The issue is that "string" searchable-only attributes do not have an "untouched" subfield version (like option_text_color.untouched) of type "keyword" on which you can safely perform it. So you'll probably need to target the base field of a searchable-only text attribute (like "name") which is of type "text" but has the "keyword" analyzer.
It looks like a query like this works as expected :
{
"size": 20,
"sort": [
{
"_score": {
"order": "desc"
}
},
{
"entity_id": {
"order": "desc",
"missing": "_first",
"unmapped_type": "keyword"
}
}
],
"from": 0,
"query": {
"term": {
"name": "Joust Duffle Bag"
}
}
}
You would need to check that this approach works for all string/text attributes susceptible of appearing in the rules engine either because
- they are searchable only
- or they are filterable (we allow it, so meh...) only
- or they are sortable only
- or they have "use in promo rules" flag set to yes only
- any combination of the above
Regards,
PS: As a side note, if you add "is", you should also probably add "is not" as a way to exclude a particular product in the context of a more complex rule. The negation should be taken care of automatically in the QueryBuilder on those lines.
hey @rbayet ,
sorry for the late response!
I've created another pull request, because it combines another issue.
https://github.com/Smile-SA/elasticsuite/pull/3230
Regards Marcus