watson-developer-cloud / discovery-components

IBM Watson Discovery components
https://watson-developer-cloud.github.io/discovery-components/storybook
Apache License 2.0
22 stars 38 forks source link

fix: fixed error in search results due to document title #550

Closed aryashah27 closed 6 months ago

aryashah27 commented 6 months ago

What do these changes do/fix?

When using search, regardless of user query (empty or with actual strings), the message There was an error rendering SearchResults, when the code doesn't find document title where it is supposed to be. With this fix, it handles the case where title is its own separate field in the document with the format "title": { "a": 1, "text": "title text" }. If the field title is an object and doesn't have a field text in string format, just returns the toString() so that would result in displaying [object Object]. This would prevent the component from crashing.

Github issue: 16447

How do you test/verify these changes?

  1. Download test.json.zip
  2. Unzip the file
  3. Create a collection by uploading test.json
  4. Once the collection is created, go to Improve and Customize
  5. No need to type something in the search bar, just hit enter
  6. You should get the results with the title text as a part of the results

Have you documented your changes (if necessary)?

Are there any breaking changes included in this pull request?