schema
TagField("$.id", as_name="id"),
TextField("$.brand", as_name="brand"),
TextField("$.title", as_name="title"),
TextField("$.category", as_name="category"),
TextField("$.param", as_name="param"),
TextField("$.tags", as_name="tags"),
NumericField("$.price", as_name="price"),
NumericField("$.comments.positive_ratio", as_name="positive_ratio"),
query
FT.SEARCH sku:idx "@category:耳机 AND @brand:(华为) AND @price:[1500 2000]" LANGUAGE chinese
query explain
Explain with language chinese
FT.EXPLAIN sku:idx "@category:耳机 AND @brand:(华为) AND @price:[1500 2000]" LANGUAGE chinese
INTERSECT {
UNION {
@category:耳机
INTERSECT {
耳机(expanded)
}
}
UNION {
@brand:华为
INTERSECT {
华为(expanded)
}
}
NUMERIC {1500.000000 <= @price <= 2000.000000}
}
Explain without chinese
FT.EXPLAIN sku:idx "@category:耳机 AND @brand:(华为) AND @price:[1500 2000]"
INTERSECT {
@category:UNION {
@category:耳机
@category:+耳机(expanded)
}
@brand:UNION {
@brand:华为
@brand:+华为(expanded)
}
NUMERIC {1500.000000 <= @price <= 2000.000000}
}
result:
One return doc of the result is as below:
{"id":"100052917480","brand":"Technics","expanded_brand":"Technics","title":"Technics尊享级 真无线入耳蓝牙立体声耳机 运动跑步耳机 适用于苹果华为小米手机 AZ80黑色","category":"数码>影音娱乐>蓝牙/无线耳机","param":"商品名称:TechnicsEAH-AZ80; 商品编号:100052917480; 商品毛重:0.6kg; 商品产地:马来西亚; 特色功能:主动降噪; 类别:降噪耳机; 音频传输协议:SBC,AAC,LDAC; 佩戴方式:入耳式; 连接方式:蓝牙","price":1999.0,"comments":{"total":100,"positive":10,"positive_ratio":0.94,"neutral":1,"neutral_ratio":0.06,"negative":0,"negative_ratio":0.0,"real_total":11,"real_positive_ratio":0.91}}
unexpected reason
The return result is a product with brand Technics not 华为, but the title contains 华为
tried methods
- add Dialect 1-3, not working
- exact match with quotes, working for this case, but not general for all cases, e.g. category=蓝牙/无线耳机, search query @category:蓝牙耳机 will return nothing