0
votes

I want to highlight the terms used in Solr search.I am doing the search and obtaining the following results.How do I highlight the term exactly using the following JSON response or am I missing something in the configuration which stops me from getting the results expected.

 {
    "_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>"
                            ]
                        ]
                    }
                ]
            }
        ]
    }
}

Please let me know If you need anything.My highlighting defaults from solrconfig.xml is as shown below.

 <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>
1
Please show your schema.xml and solrconfig.xml.Uwe Allner
My schema.xml is the default schema.xml used for other example projects.Ajay K
I don't know it either, and I don't want to guess.Uwe Allner

1 Answers

0
votes

I figured out what was the issue.The dynamic fields cannot be highlighted.The field has to be defined in schema.xml for it to be highlighted.