How to display the search result with nested data

Hi, I am trying to implement search screen using Search UI with Elasticsearch connector. The problem i m facing during displaying search result where the response data contains Json object.

The response from the elasticsearch is like this:

"_source": {

                    "doc": {
                        "year": 2020,
                        "num": 1234,
                      }
}

and in the ResultView.js code to display the year is

                        <span className="sui-result__key">Document</span>{" "}
                        <span
                            className="sui-result__value"
                            dangerouslySetInnerHTML={{
                                __html: result.doc.year.raw
                            }}
                        />
                    </li>```

Please share some tips to display the Json object returned from the response.

Hi @sandhya15

surprisingly this is a little tricky and is an outstanding bug. Nested objects are not rendered when `elasticsearch-connector` is used · Issue #907 · elastic/search-ui · GitHub

One way to do this is you have access to the rawHit within the _meta field, which can be used in the display (when you override the itemComponent)

Joe

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.