我将以下文档存储在Solr中:
doc {
id: string; // this is a unique string that looks like an md5 result
job_id: string; // this also looks like an md5 result -- this is not unique
doc_id: number; // this is a long number -- this is not unique
text: string; // this is stored, indexed text -- this is not unique
}
Run Code Online (Sandbox Code Playgroud)
现在,我要做的是计算其中包含文本foo的文档(doc_id)的数量。因此,如果这是SQL,我将要发出如下内容:
SELECT count(distinct doc_id)
FROM Doc
WHERE text like '%foo%';
Run Code Online (Sandbox Code Playgroud)
提前致谢。
为了使其工作(使用结果分组/归档折叠),您需要满足一些条件。
然后你可以这样提出请求:
/select/?q=foo&rows=0&group=true&group.field=doc_id_str&group.limit=0&group.ngroups&group.format=simple&wt=json
Run Code Online (Sandbox Code Playgroud)
这个查询对我有用。它如何为您工作,取决于您的索引和它的大小。请询问您是否需要更多指导。