我们举个例子,我们有下表,
CREATE TABLE test.employee_copy1 (
empid int,
deptid int,
firstname text,
lastname text,
solr_query text, -- column got created by enabling DSE Search
PRIMARY KEY (empid, deptid)
)
假设solrconfig.xml,schema.xml已经在 DSE搜索环境中的cassandra后面启动并运行了solr核心。
当我尝试以下查询时,
SELECT JSON * FROM test.employee_copy1 WHERE
solr_query = '{"q":"*:*",
"facet":{"field":"firstname"}}'; // LOOK HERE
我得到的结果为预期
{
"facet_fields": {
"firstname": {
"John": 154,
"Mary": 77
}
}
}
现在,我想要firstname和lastname的facet。因此我的查询将是,
SELECT JSON * FROM test.employee_copy1 WHERE
solr_query = '{"q":"*:*",
"facet":{"field":"firstname", "field":"lastname"}}'; //LOOK HERE
现在结果是,意外或错误
{
"facet_fields": {
"lastname": {
"Paul": 130,
"Abraham": 50
}
}
}
问题:DSE搜索CQL结果集JSON不会返回firstname和lastname的facet。仅在查询中的最后一个字段返回构面。
我也尝试了以下查询,但开发中心报告错误,
SELECT JSON * FROM test.employee_copy1 WHERE
solr_query = '{"q":"*:*", "facet":{"field":["firstname","lastname"]}}';
SELECT JSON * FROM test.employee_copy1 WHERE
solr_query = '{"q":"*:*", "facet":{"field":"firstname,lastname"}}';
问题: DSE搜索只能处理一个方面字段吗?
注意:我可以将两个字段传递给Solr HTTP API并获取两个字段的构面,如下所示。
http://localhost:8983/solr/test.employee/select?q=*:*&wt=json&indent=true&facet=true&facet.field=firstname&facet.field=lastname
RESPONSE:
...
{
"facet_fields": {
"firstname": [
"John",
154,
"Mary",
77
],
"lastname": [
"Paul",
130,
"Abraham",
50
]
}
}
}