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

如何将AutocompleteInput的filterToQuery操作符从eq改为ilike?

解决方法

要把查询操作符从eq替换为ilike,只需调整filterToQuery函数的返回结构,将字段名指定为name.ilike即可:

const filterToQuery = (searchText:string) => ({ 'name.ilike': `%${searchText}%`});

<ReferenceInput source="block_id" reference="blocks">
  <AutocompleteInput sx={{width: 1}} filterToQuery={filterToQuery} label="Block" optionText="name" />
</ReferenceInput>

说明

React Admin的PostgREST数据提供者会识别字段名.操作符这种键格式,自动将其转换为URL中的字段名=操作符.值参数结构,最终生成目标URL:
https://[host]/rest/v1/blocks?order=id.desc&offset=0&limit=1000&name=ilike.%test%

内容的提问来源于stack exchange,提问作者s.pyriaev

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 22:52:15