对CosmosDB / DocumentDB的数组进行大小写不敏感的搜索(Case insensitive search in arrays for CosmosDB / DocumentDB)
比方说,我有这些文件在我的CosmosDB。 (DocumentDB API,.NET SDK)
{ // partition key of the collection "userId" : "0000-0000-0000-0000", "emailAddresses": [ "someaddress@somedomain.com", "Another.Address@someotherdomain.com" ] // some more fields }
我现在需要知道是否有给定电子邮件地址的文档。 但是,我需要查询不区分大小写。
有一些方法可以在字段中搜索不区分大小写的字段(但它们会执行全面扫描):
如何在Azure DocumentDb上执行不区分大小写的搜索?
select * from json j where LOWER(j.name) = 'timbaktu' e => e.Id.ToLower() == key.ToLower()
这些不适用于数组。 有其他方法吗? 用户定义的函数看起来可能有所帮助。
我主要是在寻找一种暂时的低效解决方案来支持这种情况(我有这样的多个集合)。 我可能需要在某个时候切换到这样的数据结构:
{ "userId" : "0000-0000-0000-0000", // Option A "emailAddresses": [ { "displayName": "someaddress@somedomain.com", "normalizedName" : "someaddress@somedomain.com" }, { "displayName": "Another.Address@someotherdomain.com", "normalizedName" : "another.address@someotherdomain.com" } ], // Option B "emailAddressesNormalized": { "someaddress@somedomain.com", "another.address@someotherdomain.com" } }
不幸的是,我的生产数据库已经包含需要更新以支持新结构的文档。 我的生产集合中只包含100个这样的项目,所以我甚至想要获取所有项目并在客户端的内存中进行比较。
Lets say I have these documents in my CosmosDB. (DocumentDB API, .NET SDK)
{ // partition key of the collection "userId" : "0000-0000-0000-0000", "emailAddresses": [ "someaddress@somedomain.com", "Another.Address@someotherdomain.com" ] // some more fields }
I now need to find out if I have a document for a given email address. However, I need the query to be case insensitive.
There are ways to search case insensitive on a field (they do a full scan however):
How to do a Case Insensitive search on Azure DocumentDb?
select * from json j where LOWER(j.name) = 'timbaktu' e => e.Id.ToLower() == key.ToLower()
These do not work for arrays. Is there an alternative way? A user defined function looks like it could help.
I am mainly looking for a temporary low-effort solution to support the scenario (I have multiple collections like this). I probably need to switch to a data structure like this at some point:
{ "userId" : "0000-0000-0000-0000", // Option A "emailAddresses": [ { "displayName": "someaddress@somedomain.com", "normalizedName" : "someaddress@somedomain.com" }, { "displayName": "Another.Address@someotherdomain.com", "normalizedName" : "another.address@someotherdomain.com" } ], // Option B "emailAddressesNormalized": { "someaddress@somedomain.com", "another.address@someotherdomain.com" } }
Unfortunately, my production database already contains documents that would need to be updated to support the new structure. My production collections contain only 100s of these items, so I am even tempted to just get all items and do the comparison in memory on the client.
原文:https://stackoverflow.com/questions/47596474
最满意答案
关于这个wiki的
testthat
包有很好的文档: https : //github.com/hadley/devtools/wiki/Testing简而言之,您可以在每个
test_that
嵌入多个expect_that
语句。在页面的末尾,在“测试文件和目录”部分中,有关于三个不同报告者的信息(停止,最小和摘要)。
我发现这非常强大。 即使test_that发现错误,它也只是报告错误并继续进行其余的测试。
PS。 我的经验是将测试结果打印到控制台。 我在R环境中运行我的测试,而不是OS命令行。
There is a very good documentation about the
testthat
package at this wiki: https://github.com/hadley/devtools/wiki/TestingIn a nutshell, you can embed multiple
expect_that
statements in eachtest_that
.Towards the end of the page, in the section 'Testing files and directories' there is information about the three different reporters (stop, minimal and summary).
I have found this to be quite robust. Even if test_that finds an error, it simply reports the error and carries on with the remainder of the tests.
PS. My experience is that the test results are printed to the console. I run my testing from within the R environment, not the OS command line.
相关问答
更多-
LINUX 如何查看JPG文件[2022-06-13]
find -
对于每个测试gitlab-ci清理构建文件夹,因此构建阶段的输出文件在部署阶段不可用。 您还需要在部署阶段重建您的项目。 这些“阶段”仅用于订购测试,即避免在构建测试失败时尝试执行部署测试。 编辑:自Gitlab 8.6以来,可以使用依赖项功能 For each test gitlab-ci clean the build folder, therefore the output files of the build stage are not available in the deploy stage. ...
-
目前,您没有指定终止条件: lexer([H|TokenList],Output,[Output|X2]):- lexer_test(H,Output),lexer(TokenList,Output,X2). Lexer一直在调用自己(递归),但是你没有指定其他子句,因此Prolog最终会进入无限循环。 您正在寻找的条件是: lexer([],_,[]). 作为停止条件。 这表明令牌列表变空的情况。 开始学习prolog(imho)的好地方是: http : //www.learnprologno ...
-
我建议在输出中为unix时间戳添加另一个字段。 在gnu find的-printf格式字符串中,这表示为%T@ 。 例如,要排序你可以做的所有事情: find / -type f -printf "%T@ Date: %TY-%Tm-%Td - Time: %TT - File: %f\n" \ | LC_ALL=C sort -n -k1,1 \ | cut -d' ' -f2- sort -n -k1,1在stdin中对第一列(仅包含第一列)中的行进行数字排序。 LC_ALL=C环境变 ...
-
你不能提供Windows本机程序Cygwin路径,他们不明白。 但是,您可以将包装器脚本放在与ffmpeg.exe相同的文件夹中,并将其命名为ffmpeg 。 喜欢这个 #!/bin/sh for each do foo=$(cygpath -w -- "$each") bar+=("$foo") done ffmpeg.exe "${bar[@]}" 然后你就离开了 $ ffmpeg.exe -i 1_Les_Nuits.mp3 /tmp/outfile.m4a /tmp/outfile.m4a ...
-
构建gmp(gcc的先决条件)时会产生此错误。 这是4.8.3 Ref:gmp bug中gmp中的一个已知错误 。 如果运行contrib / download_prerequisites,默认情况下会得到gmp 4.8.3。 解决方法是编辑gmp-4.8.3 / configure.in和gmp-4.8.3 / configure和change M4=m4-not-required 对于 M4=m4 This error is generated whilst building gmp (a pre-re ...
-
你可能想要执行一个shell。 就像是: find . -type f -name \*.mp4 -exec sh -c 'ffprobe "$0" 2>&1 | grep -q 1920x1080 && echo "$0"' {} \; You probably want to exec a shell. Something like: find . -type f -name \*.mp4 -exec sh -c 'ffprobe "$0" 2>&1 | grep -q 1920x10 ...
-
关于这个wiki的testthat包有很好的文档: https : //github.com/hadley/devtools/wiki/Testing 简而言之,您可以在每个test_that嵌入多个expect_that语句。 在页面的末尾,在“测试文件和目录”部分中,有关于三个不同报告者的信息(停止,最小和摘要)。 我发现这非常强大。 即使test_that发现错误,它也只是报告错误并继续进行其余的测试。 PS。 我的经验是将测试结果打印到控制台。 我在R环境中运行我的测试,而不是OS命令行。 Ther ...
-
它可能在~/Library/Developer/Xcode/DerivedData/某处。 It's probably in ~/Library/Developer/Xcode/DerivedData/ somewhere.
-
找不到libstdc ++?(Can't find libstdc++?)[2022-12-19]
从你的评论中看出,你用gcc而不是g++ 。 不要把它当成错误,因为编译很好! 出现的是链接器错误。 实际上, gcc会告诉ld链接C标准库而不是C ++标准库。 要解决,要么直接使用g++ ,要么传递-lstdc++ 。 As turns out from your comment, you compiled with gcc rather than g++. Do not take it as an error, as the compilation went fine! What's showing ...