Solr:当匹配= 1且NGroups = 1时,没有返回任何组(Solr: No Groups returned when Matches = 1 and NGroups = 1)
I am querying solr and results are grouped. Everything is working fine until I make a specific query which returns (supposedly) only 1 result. Debugging shows that there was a match and a ngroup, but no groups are returned from solr. Any pointers to the solution would be appreciated.
原文:https://stackoverflow.com/questions/40784360
最满意答案
FUN=my.mse
正在劫持你的lapply
apply
尝试。 我想你想要:lapply(B.list, function(x) apply(x, 2, my.mse))
您不能为
lapply
指定FUN
并在同一个调用中应用(除非您使用Konrad建议的位置匹配)。 发生了什么事情,你的电话匹配是这样的:lapply(B.list, FUN=my.mse, ...=list(apply, MARGIN=2))
然后在第一次迭代中导致尝试评估:
my.mse(B.list[[1]], apply, MARGIN=2)
而不是你期望的
apply(B.list[[1]], 2, my.mse)
。 由于my.mse
只接受一个参数,因此您会收到有关“unused arguments”的错误。 仔细观察,“未使用的参数”是apply
函数的主体。
FUN=my.mse
is hijacking your attempt tolapply
apply
. I think you want:lapply(B.list, function(x) apply(x, 2, my.mse))
You can't specify
FUN
for bothlapply
andapply
in the same call (unless you use positional matching as Konrad suggests). What's happening is that your call is getting matched like so:lapply(B.list, FUN=my.mse, ...=list(apply, MARGIN=2))
Which then in your first iteration leads to the attempt to evaluate:
my.mse(B.list[[1]], apply, MARGIN=2)
instead of your expected
apply(B.list[[1]], 2, my.mse)
. Sincemy.mse
only accepts one argument, you get the error about "unused argument". If you look closely, the "unused argument" is the body of theapply
function.
相关问答
更多-
在使用公式时,您通常还需要为data参数提供值,以便函数知道要使用哪些数据。 您的数据集将成为列表元素,因此您需要使用匿名函数将它们提供给perm.test。 在这种情况下请尝试: testperm <- lapply(test.list, FUN=function(x) perm.test(formula=(cover ~ group),data=x)) When you use a formula, you often also need to supply a value to a data ar ...
-
输出定向到同一文件的原因可能是file = paste0(names(DF), "txt", sep=".")为每次迭代返回相同的值。 也就是说, DF在每次迭代中必须具有相同的列名,因此names(DF)将是相同的,而paste0(names(DF), "txt", sep=".")将是相同的。 与append = TRUE选项一起,结果是所有输出都写入同一文件。 在匿名函数中, x是输入文件的名称。 您可以对此字符串进行一些转换,而不是使用names(DF)作为输出文件名的基础。 例。 特定 x <- ...
-
将for循环转换为apply / lapply / sapply:基于列的操作(Converting for loop to apply/lapply/sapply: column based operations)[2024-01-21]
如果你真的想在这里使用apply ,你可以这样做: n_rows = 20 Dir = data.frame( a = sample(1:100, n_rows), b = sample(1:100, n_rows), c = sample(c(NA, 1, 2), n_rows, replace = TRUE), d = sample(1:100, n_rows), e = sample(1:100, n_rows) ) # MARGIN = 1: apply a ... -
如果我们使用lapply ,请使用lapply创建列 lapply(pval, transform, classe = as.integer(X4 %in% causal_snp)) 在OP的代码中,在赋值之后,我们需要返回x lapply(pval, function(x) {x$classe=ifelse(x$X4 %in% causal_snp, 1, 0);x}) If we are using lapply, create the column with transform lapply(p ...
-
我很困惑 - data.frame所有list之后。 所以除了明显的 R> testdf <- data.frame(t=seq(1,5,1),e=seq(6,10,1)) R> mean(testdf) t e 3 8 R> mean(mean(testdf)) [1] 5.5 R> 你也可以这样做 R> lapply(testdf, mean) $t [1] 3 $e [1] 8 R> mean(unlist(lapply(testdf, mean))) [1] 5.5 R> 那么内部的 ...
-
这应该工作 lapply(s, function(x) { diag(x) <- 0; x}) 这相当于 lapply(s, function(x) { diag(x) <- 0 return(x)}) 请注意,这是有效的,因为匿名函数有一个返回的对象,它表示后; 或明确地作为return(x) This should work lapply(s, function(x) { diag(x) <- 0; x}) which is equivalent to lapply(s, function ...
-
如何从lapply-attack中保存我的矩阵列表的结构?(How to save the structure of my list of matrices from lapply-attack?)[2022-01-25]
你必须在lapply函数中返回值: mtList1 = lapply(mtList,function(x) { x[] = as.numeric(x) x }) str(mtList1) # List of 2 # $ : num [1:5, 1:2] 1 7 6 3 9 10 5 2 8 4 # $ : num [1:7, 1:3] 21 3 15 14 6 4 18 17 9 8 ... You have to return the value in your lapply workho ... -
首先,我们应该找到检索一条线的正确方法。 因此,对于第1行(1,1,1) 我们想循环L的三个元素并检索M中第1行索引的矩阵 col.ids <- unlist(M[1,]) # sapply will already return the columns in a matrix # We use seq_along rather than looping directly on L, because we also need the # id for col.ids sapply(seq_along(L), ...
-
嵌套应用于lapply以循环遍历矩阵列的列(Nesting apply in lapply to loop over columns of a list of matrices)[2020-12-05]
FUN=my.mse正在劫持你的lapply apply尝试。 我想你想要: lapply(B.list, function(x) apply(x, 2, my.mse)) 您不能为lapply指定FUN并在同一个调用中应用(除非您使用Konrad建议的位置匹配)。 发生了什么事情,你的电话匹配是这样的: lapply(B.list, FUN=my.mse, ...=list(apply, MARGIN=2)) 然后在第一次迭代中导致尝试评估: my.mse(B.list[[1]], apply, MA ... -
正如docendo discimus建议你可以使用mapply l <- list(matrix(1:4, ncol = 2), matrix(5:8, ncol = 2), matrix(9:12, ncol = 2)) v <- 1:3 mapply(function(x,y) x*y, x = l, y = v, SIMPLIFY = FALSE) 或者只使用Map Map("*", l, v) As docendo discimus suggested you can use mapply ...