You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flexi Search关联查询IS NULL关键字失效问题求助

解决Flexi查询单字段为空无结果的问题

你当前的查询用了内连接(join),只要AviationDispute的deliveryId或invoiceId其中一个为空,内连接就会直接过滤掉这条争议记录,所以只有两个字段都有值时才会返回结果。

把连接方式改成左连接(left join),同时调整where条件区分两种单字段存在的场景,就能解决问题:

select {p:pk} 
from {AviationDispute as p 
left join AviationB2BDocuments as a on {p:invoiceId}={a:pk} 
left join AviationDelivery as d on {p:deliveryId} = {d:pk}} 
where 
({p:deliveryId} is not null and {d:deliveryId} LIKE '%searchTerm%') 
or 
({p:invoiceId} is not null and {a:invoiceNumber} LIKE '%searchTerm%')

关键修改点:

  • 用left join替代join:即使deliveryId或invoiceId为空,AviationDispute的基础记录也会被保留
  • where条件拆分:分别针对「运单存在且匹配搜索词」、「发票存在且匹配搜索词」两种情况做判断,确保单字段提交的争议能被命中

内容的提问来源于stack exchange,提问作者siddarth

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 22:57:22