无法按孩子过滤并将结果扩展到solr中的孙子

问题描述 投票:0回答:1

我们需要什么:我们想要所有在特定纬度和经度范围内具有机构的文档,并且对于这些文档,我们希望返回该文档的所有子文档。

一个文档如下:

{
        "optionId":568510,
        "id":"Major-568510-5",
        "optionName":"Major A",
        "category":"Major",
        "_version_":1802116777088385024,
        "institutions":[
          {
            "stateProvId":47,
            "institutionSpatialField":37.123,-81.213
            "institutionName":"University A",
            "id":"MajorInstitution-568510-406-4",
            "_nest_path_":"/institutions",
            "category":"MajorInstitution",
            "_version_":1802116777088385024,
            "degrees":[
              {
                "degreeTypeId":3,
                "id":"MajorInstitutionDegree-568510-406-20-3-5",
                "_nest_path_":"/institutions/degrees",
                "category":"MajorInstitutionDegree",
                "_version_":1802116777088385024}]}
          {
            "stateProvId":14,
            "institutionName":"University B",
            "institutionSpatialField":38.123,-80.213
            "id":"MajorInstitution-568510-408-4",
            "_nest_path_":"/institutions",
            "category":"MajorInstitution",
            "_version_":1802116777088385024,
            "degrees":[
              {
                "degreeTypeId":2,
                "id":"MajorInstitutionDegree-568510-408-19-2-5",
                "_nest_path_":"/institutions/degrees",
                "category":"MajorInstitutionDegree",
                "_version_":1802116777088385024}]}
}

每个文档都是一个专业。每个专业都有一个机构列表,每个机构都有一个学位列表。

我们使用 Solr 版本 8.1。

我们尝试过的:

我们尝试使用childFilter,如下所示:

q=*:*&fq=category:(Major)&fl=*, [child childFilter="institutions/institutionSpatialField:[37.1,80 TO 38.1,82.13]"]]
基本上,添加一个 childFilter 来过滤搜索的经纬度范围。 问题在于结果仅限于机构层面。如下:

{
        "id":"Major-568510-5",
        "optionName":"Major A",
        "category":"Major",
        "_version_":1802116777088385024
        "institutions":[
          {
            "stateProvId":47,
            "institutionName":"University A",
            "institutionSpatialField":37.123,-81.213,
            "id":"MajorInstitution-568510-406-4",
            "_nest_path_":"/institutions",
            "_version_":1802116777088385024},
          
}

但是,我们还想获得过滤后文档的度数。

solr solrcloud
1个回答
0
投票

按照以下步骤:https://solr.apache.org/guide/solr/latest/query-guide/searching-nested-documents.html#child-query-parser

我认为你可以:

q={!parent which = '-_nest_path_:* optionId:*'}institutionSpatialField:[37.1,80 TO 38.1,82.13]&fq=category:(Major)&fl=*, [child]

© www.soinside.com 2019 - 2024. All rights reserved.