Solr -如何获得父文档的子文档,其中父文档是由多个标准筛选的?

yhxst69z  于 2022-11-05  发布在  Solr
关注(0)|答案(1)|浏览(187)

我在solr中有类似于以下结构的文档:

[
    {
        "id": "stationId-37246",
        "type": "station",
        "territory": "372",
        "genres":
        {
            "id": "genreId-37246-a4nm24kgsadvmdv4cgemt-20-372-ga",
            "type": "genre",
            "genre_type": "station",
            "genre_href": "3.1.1.11",
            "_nest_path_": "/genres#"
        }
    },
    {
        "id": "stationId-3724",
        "territory": "372",
        "type": "station",
        "genres":
        {
            "id": "genreId-3724-ep7tvwiiekl9ud8vewhjb-3-372-ga",
            "type": "genre",
            "genre_type": "station",
            "genre_href": "3.1.1",
            "_nest_path_": "/genres#"
        }
    },
    {
        "id": "stationId-37245",
        "territory": "372",
        "type": "station",
        "genres":
        {
            "id": "genreId-37245-4osajn644rg7p3jd8jqu8m-20-372-ga",
            "type": "genre",
            "genre_type": "station",
            "genre_href": "3.1.1.11",
            "_nest_path_": "/genres#"
        }
    },
    {
        "id": "odId-37248",
        "territory": "372",
        "type": "ondemand",
        "genres":
        {
            "id": "genreId-37248-y1wljbe9uus1m25yqie23s-122-372-ga",
            "type": "genre",
            "genre_type": "ondemand",
            "genre_href": "3.1.5.2",
            "_nest_path_": "/genres#"
        }
    },
    {
        "id": "stationId-44449",
        "territory": "444",
        "type": "station",
        "genres":
        {
            "id": "genreId-44449-y1wljbe9uus1m25yqie23s-122-372-ga",
            "type": "genre",
            "genre_type": "station",
            "genre_href": "3.1.5.4",
            "_nest_path_": "/genres#"
        }
    }
]

我需要能够给予一个流派的列表,为一个特定的领土和为一个特定的流派类型。
例如,我希望能够获得流派列表,这些流派与位于区域372中的父母相关联,并且具有genre_type:station。
上面的示例应生成如下所示的内容:

[
    {
        "id": "genreId-37246-a4nm24kgsadvmdv4cgemt-20-372-ga",
        "type": "genre",
        "genre_type": "station",
        "genre_href": "3.1.1.11",
        "_nest_path_": "/genres#"
    },
    {
        "id": "genreId-37245-4osajn644rg7p3jd8jqu8m-20-372-ga",
        "type": "genre",
        "genre_type": "station",
        "genre_href": "3.1.1.11",
        "_nest_path_": "/genres#"
    },
    {
        "id": "genreId-3724-ep7tvwiiekl9ud8vewhjb-3-372-ga",
        "type": "genre",
        "genre_type": "station",
        "genre_href": "3.1.1",
        "_nest_path_": "/genres#"
    }
]

但如果我想要相同类型的流派,对于444区,我会得到

{
    "id": "genreId-44449-y1wljbe9uus1m25yqie23s-122-372-ga",
    "type": "genre",
    "genre_type": "station",
    "genre_href": "3.1.5.4",
    "_nest_path_": "/genres#"
}

有什么建议吗?我正在尝试执行各种伏都教,但我发现solr文档站点有点难以理解。
因此,下面的表达式将正确返回:

"params":
        {
            "q": "{!child of=\"+type: station\"}territory:372",
            "fq":
            [
                "genre_type: station",
                "type: genre"
            ],
        }

但是这个方法抛出了如下相同的错误:
第一个

hgncfbus

hgncfbus1#

看起来出于某种原因,SOLR想要真正确定我的意图,我必须重复我自己:

{
    "params":
    {
        "q": "{!child of=+type:station}(territory:372 +type:station)",
        "fq":
        [
            "type: genre",
            "genre_type: station"
        ],
    }
}

{
    "params":
    {
        "q": "{!child of=+type:ondemand}(territory:372 +type:ondemand)",
        "fq":
        [
            "type: genre",
            "genre_type: ondemand"
        ],
    }
}

相关问题