首页 > 解决方案 > 如何在 solr 的多值字段中搜索并将结果映射到多值字段中?

问题描述

我正在使用 solr 4.10.3 并在多值字段上执行搜索操作。我的数据如下所示 -

"id": 1234567,
"type": "Standard",
"headline": [
          "horlics",
          "horlics new",
          "horlics new test"
        ],
"headline_string": [
          "horlics",
          "horlics new",
          "horlics new test"
        ]

我必须对标题执行搜索,并且我正在使用以下代码 -

GroupOptions groupOptions = new GroupOptions().addGroupByField(field);
        query.addProjectionOnField("headline_string");
        query.setGroupOptions(groupOptions);
        query.setPageRequest(page);
        return solrTemplate.queryForGroupPage(query, MyClass.class);

但它给出了“不能在多值字段上使用 FieldCache”的错误。

我也尝试使用 FacetQuery -

FacetQuery facetQuery = new SimpleFacetQuery(new Criteria("headline").contains("new"));
        FacetOptions facetOptions = new FacetOptions();
        facetQuery.setFacetOptions(facetOptions.addFacetOnField(s).setPageable(page));
        FacetPage<MyClass> facetPage = solrTemplate.queryForFacetPage(facetQuery, MyClass.class);

这给了我所有与我的标准不匹配的结果。欢迎任何建议。

谢谢。

标签: spring-bootsolrspring-data-solr

解决方案


推荐阅读