on 2021 Mar 02 4:59 PM
Hello expert,
I try to understand the caret symbol. what is the significant of ^ symbol in a flexible search query ?
Select * from {AbstractCmsComponent^ as p1}
Thanks in advance ��
I couldn't find any documentation but I remember seeing explanation of the usage for caret (^) symbol. If I find it, I'll update my answer with the related documentation.
Anyway, I dig into Flexible Search Translation (in version 1905.24) from code side and I found out that there are 3 characters which are used along with the type name in the Flexible Search Query which are (!), (*) and (^). Related code can be found under ParsedType.class (package: de.hybris.platform.persistence.flexiblesearch, method: public static String[] splitTypeExpression(String expr) ).
In that method, these characters are related with the following strings
(!) : "exact"
(*) : "alltypes"
(^) : "deploymenttypes"
You can find the detailed explanation for (!) character (matched with "exact" keyword) in https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/2011/en-US/b3c53d29850c47faa977f0cda707...
And the code in FromClause.class has a constructor call for these matches as follows:
ParsedType parsedType = new ParsedType(this, typeCode, alias, noSubtypes, disableTypeChecks, excludeSubtypesWithOwnDeployment);
noSubtypes is true when "exact" is used
disableTypeChecks is true when "alltypes" is used
excludeSubtypesWithOwnDeployment is true when "deploymenttypes" is used
This looks likes it's saying something but it's better for understanding the cases with an example.
For example, I will use AbstractCoupon from couponservices extension and CustomerCoupon from customercouponservices extension which extends AbstractCoupon.
Both types have their own deployment tables.
When we search without any of it
SELECT {PK} FROM {AbstractCoupon AS c}
It will be translated as follows
SELECT item_t0.PK FROM coupon item_t0 WHERE (item_t0.TypePkString IN (?,?,?) ) UNION ALL SELECT item_t0.PK FROM customercoupons item_t0 WHERE (item_t0.TypePkString=? )
Replaced parameters: [8796136538194, 8796136505426, 8796136472658, 8796136603730]
Since CustomerCoupon extends AbstractCoupon, it's translated as a UNION query.
If we use (!) in the query
SELECT {PK} FROM {AbstractCoupon! AS c}
It will be translated as follows
SELECT item_t0.PK FROM coupon item_t0 WHERE (item_t0.TypePkString=? )
Replaced parameters: [8796136472658]
By using (!) along with AbstractCoupon we achieved "noSubtype" meaning only items with type AbstractCoupon are queried.
If we use (*) in the query
SELECT {PK} FROM {AbstractCoupon* AS c}
It will be translated as follows
SELECT item_t0.PK FROM coupon item_t0
By using (*) we achieved "disableTypeChecks", meaning no restriction on TypePKString field is applied and the deployment table is queried for the type AbstractCoupon
If we use (^) in the query
SELECT {PK} FROM {AbstractCoupon^ AS c}
It will be translated as follows:
SELECT item_t0.PK FROM coupon item_t0 WHERE (item_t0.TypePkString IN (?,?,?) )
Replaced parameters: [8796136538194, 8796136505426, 8796136472658]
By using (^) we achieved "excludeSubtypesWithOwnDeployment" meaning that we ignored the deployment tables of subtypes and queried only the super type's deployment table
Note that, translated query looks very similar to the one with (!), however, the difference is that main database table is queried with the TypePK values of the subtypes. In (!) only the super type's TypePK value is used.
Also note that, to be able to use these characters, the type should have a deployment table. When you try using (^) with AbstractOrder it will have no effect. When you use (*) with AbstractOrder it gives error, but not an explained one. And when you try using (!) with AbstractOrder it gives you the following Exception.
cannot search on abstract type 'AbstractOrder' with no-subtypes option ('!')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
26 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.