无法在DSE搜索中的一个solr CQL查询中获取文档和方面

时间:2017-05-31 16:33:01

标签: solr datastax datastax-enterprise cql3 cassandra-3.0

要求:是使用 DSE搜索

实施分面搜索

问题:无法在一个CQL solr查询中获取文档或数据以及 facets

工具&使用的技术: Datastax Sandbox 5.1(Cent OS +虚拟盒)和尝试DSE搜索

创建以下表格&使用dsetool enable solr( DSE搜索):

CREATE TABLE test.employee_copy1 (
    empid int,
    deptid int,
    name text,
    solr_query text, -- column got created by enabling DSE Search
    PRIMARY KEY (empid, deptid)
)

插入以下数据,

INSERT INTO employee (empid,deptid,name) VALUES (100,200,'John');
INSERT INTO employee (empid,deptid,name) VALUES (101,201,'Helen');
INSERT INTO employee (empid,deptid,name) VALUES (102,201,'John');

我尝试了Solr Admin的facet查询,如下所示

http://localhost:8983/solr/test.employee/select?q=*:*&wt=json&indent=true&facet=true&facet.field=name

得到的结果包含所需的文档(或数据)和构面

{
    "responseHeader": {
        "status": 0,
        "QTime": 1
    },
    "response": {
        "numFound": 3,
        "start": 0,
        "docs": [{
                "_uniqueKey": "[\"100\",\"200\"]",
                "empid": 100,
                "deptid": 200,
                "name": "John"
            },
            {
                "_uniqueKey": "[\"101\",\"201\"]",
                "empid": 101,
                "deptid": 201,
                "name": "Helen"
            },
            {
                "_uniqueKey": "[\"102\",\"201\"]",
                "empid": 102,
                "deptid": 201,
                "name": "John"
            }
        ]
    },
    "facet_counts": {
        "facet_queries": {},
        "facet_fields": {
            "name": [
                "john", 2,
                "helen", 1
            ]
        },
        "facet_dates": {},
        "facet_ranges": {},
        "facet_intervals": {}
    }
}

但是当尝试在Datastax devcenter中的以下查询(CQL)期望看到数据和方面时,我只看到方面

select JSON * from test.employee where solr_query = '{"q":"*:*", "facet" : {"field":"name"}}';

得到了结果,但它只有facets而不是数据:

{"facet_fields" : {"name" : {"john" : 2,"helen" : 1 } } }

问题:有人可以解释为什么CQL查询无法指定"q":"*:*"而无法返回数据吗?

2 个答案:

答案 0 :(得分:0)

与HTTP查询接口不同,它是not possible从DSE 5.1(或任何早期版本)中的单个CQL solr_query获取行结果和方面。

答案 1 :(得分:0)

这只是一个产品决定。正如Caleb指出的那样,开发人员解析结果的经验被认为不太理想。此外,对于分布式P2P数据存储区(C *),发布2个异步查询的方法,1个方面结果和1个“前10个”是首选查询模式。它们不必连续完成。

最终,如果需要Solr行为,则可以在DSE中使用Solr HTTP API。 CQL API的目标更多是为C *数据提供简单的FTS,不一定支持或完成通过CQL实现的所有vanilla。