使用 JSON 结果在 Solr 中突出显示

Hightlight in Solr using JSON result

我想突出显示 Solr 中使用的术语 search.I 正在搜索并获得以下内容 results.How 我是使用以下 JSON 响应准确突出显示术语还是我配置中遗漏了一些东西,使我无法获得预期的结果。

 {
    "_header": {
        "nvPairs": [
            "status",
            0,
            "QTime",
            1,
            "params",
            {
                "nvPairs": [
                    "hl.fragsize",
                    "100000",
                    "hl.simple.pre",
                    "<em>",
                    "hl.fl",
                    "name",
                    "wt",
                    "javabin",
                    "hl.maxAnalyzedChars",
                    "100000",
                    "hl",
                    "true",
                    "version",
                    "2",
                    "hl.highlightMultiTerm",
                    "true",
                    "hl.snippets",
                    "100",
                    "hl.useFastVectorHighlighter",
                    "true",
                    "q",
                    "Ajay",
                    "hl.regex.slop",
                    "0.5",
                    "hl.regex.pattern",
                    "[-\w ,/\n\\"']*",
                    "hl.simple.post",
                    "</em>"
                ]
            }
        ]
    },
    "_results": [
        {
            "id": "1",
            "last_modified": "Jul 10, 2015 12:30:00 PM",
            "name": [
                "Ajay"
            ],
            "last_name": "Kalkoti",
            "mobile": "11",
            "_version_": 1508131686161842200
        }
    ],
    "_highlightingInfo": {
        "nvPairs": [
            "1",
            {
                "nvPairs": [
                    "name",
                    [
                        "<em>Ajay</em>"
                    ]
                ]
            }
        ]
    },
    "_highlighting": {
        "1": {
            "name": [
                "<em>Ajay</em>"
            ]
        }
    },
    "elapsedTime": 10,
    "response": {
        "nvPairs": [
            "responseHeader",
            {
                "nvPairs": [
                    "status",
                    0,
                    "QTime",
                    1,
                    "params",
                    {
                        "nvPairs": [
                            "hl.fragsize",
                            "100000",
                            "hl.simple.pre",
                            "<em>",
                            "hl.fl",
                            "name",
                            "wt",
                            "javabin",
                            "hl.maxAnalyzedChars",
                            "100000",
                            "hl",
                            "true",
                            "version",
                            "2",
                            "hl.highlightMultiTerm",
                            "true",
                            "hl.snippets",
                            "100",
                            "hl.useFastVectorHighlighter",
                            "true",
                            "q",
                            "Ajay",
                            "hl.regex.slop",
                            "0.5",
                            "hl.regex.pattern",
                            "[-\w ,/\n\\"']*",
                            "hl.simple.post",
                            "</em>"
                        ]
                    }
                ]
            },
            "response",
            [
                {
                    "id": "1",
                    "last_modified": "Jul 10, 2015 12:30:00 PM",
                    "name": [
                        "Ajay"
                    ],
                    "last_name": "Kalkoti",
                    "mobile": "11",
                    "_version_": 1508131686161842200
                }
            ],
            "highlighting",
            {
                "nvPairs": [
                    "1",
                    {
                        "nvPairs": [
                            "name",
                            [
                                "<em>Ajay</em>"
                            ]
                        ]
                    }
                ]
            }
        ]
    }
}

如果您需要 anything.My 突出显示 solrconfig.xml 中的默认值,请告诉我,如下所示。

 <str name="hl">on</str>
         <str name="hl.fl">name_s</str>
         <str name="hl.preserveMulti">true</str>
         <str name="hl.encoder">html</str>
         <str name="hl.simple.pre">&lt;b&gt;</str>
         <str name="hl.simple.post">&lt;/b&gt;</str>
         <str name="f.title.hl.fragsize">0</str>
         <str name="f.title.hl.alternateField">title</str>
         <str name="f.name.hl.fragsize">100</str>
         <str name="f.name.hl.alternateField">name</str>
         <str name="f.content.hl.snippets">3</str>
         <str name="f.content.hl.fragsize">200</str>
         <str name="f.content.hl.alternateField">content</str>
       <str name="f.content.hl.maxAlternateFieldLength">750</str>

我弄明白了 issue.The 动态字段不能是什么 highlighted.The 字段必须在 schema.xml 中定义才能突出显示。