我想用ReQL过滤一个表,使用一个(Python)字符串列表(可变值的数量)应用于几个字段,即在列表中字符串越多的逻辑中,结果越准确。理想情况下,过滤应该是案例激励性的。
SQL等效项可能类似于:
select * from mytable
where (field1 like '%AA%' and field1 like '%BB%'...)
or (field2 like '%AA%' and field2 like '%BB%'...)
or (field3 like '%AA%' and field3 like '%BB%'...)
...我测试了很多解决方案,但都没有成功,intance描述了here:
selection = list(r.table("mytable").filter(lambda d:
r.expr(searchWords).contains(d["field"])
).run(g.rdb_conn))但返回0 doc (?)。
发布于 2019-03-26 04:50:39
回答我自己的问题。对于那些可能感兴趣的人,我最终通过以下方式解决了这个问题:
在输入string
selectionDict = list(r.table('mytable').filter( \
( r.row["field1"].match("(?i)"+searchWord)) \
| (r.row["field2"]["body"].match("(?i)"+searchWord) ) ) \
.pluck("id") \
.run(g.rdb_conn))get_all的所有单词,然后使用DocID来检索和返回它们。注意,搜索是不区分大小写的,在多个字段上,可以使用我最初想要的部分单词。这可能不是最好、最干净的方法,但至少适用于不太大的数据库。
https://stackoverflow.com/questions/55319399
复制相似问题