Rethinkdb字符串匹配两个数组

Rethinkdb string match two arrays

我有两个只包含我想要匹配的字符串的数组。

我不能使用 contains 或 setIntersection,因为我希望不区分大小写的匹配也能正常工作。

我尝试了很多不同的方法,但没有找到有效的解决方案。我认为这是迄今为止我想到的最好的,但它不起作用:

r.db( 'my_db' ).table( 'Table' ).hasFields( 'tags' ).filter( function( row ) { 
  return row( 'tags' ).filter( function( t ) {
    return r.expr( [ 'Foo', 'Bar', 'FooBar' ] ).filter( function( m ) {
      return t.match( '(?i)^' + m + '$' );
    } ).count().gt( 0 );
  } ).count().gt( 0 );
} );

标签列是一个字符串数组。但我认为问题是 m 不是字符串,所以我不能将它与 match 一起使用。但是如何将它转换为字符串呢?我已经尝试过 coerceTo 但它不起作用。

关于如何进行这项工作有什么想法吗?

您应该能够通过使用 .add() 而不是 + 让您的查询工作,例如:

r.expr('(?i)^').add(m).add('$')

您也可以试试这样的方法:

r.db('my_db').table('Table').hasFields('tags').filter(row =>
  row('tags').map(x => x.upcase()).setIntersect(['FOO', 'BAR', 'FOOBAR']).isEmpty().not())