diff --git a/src/lib/utils.js b/src/lib/utils.js
index ffbdcdbc..b2b8881c 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -195,12 +195,21 @@ let utils = {
* @return {string}
**/
getHighlightedValue(object, property) {
- if (!object._highlightResult
- || !object._highlightResult[property]
- || !object._highlightResult[property].value) {
- return object[property];
+ if (object._highlightResult
+ && object._highlightResult.hierarchy_camel
+ && object._highlightResult.hierarchy_camel[property]
+ && object._highlightResult.hierarchy_camel[property].matchLevel
+ && object._highlightResult.hierarchy_camel[property].matchLevel !== 'none'
+ && object._highlightResult.hierarchy_camel[property].value) {
+ return object._highlightResult.hierarchy_camel[property].value;
}
- return object._highlightResult[property].value;
+ if (object._highlightResult
+ && object._highlightResult
+ && object._highlightResult[property]
+ && object._highlightResult[property].value) {
+ return object._highlightResult[property].value;
+ }
+ return object[property];
},
/*
* Returns the snippeted value of the specified key in the specified object.
diff --git a/test/DocSearch-test.js b/test/DocSearch-test.js
index 9371b674..c6f51a41 100644
--- a/test/DocSearch-test.js
+++ b/test/DocSearch-test.js
@@ -622,6 +622,47 @@ describe('DocSearch', () => {
expect(actual[0].category).toEqual('Ruby');
expect(actual[0].subcategory).toEqual('API');
});
+
+ it('should use highlighted camel if exists and matchLevel not none', () => {
+ // Given
+ let input = [{
+ hierarchy: {
+ lvl0: 'Ruby',
+ lvl1: 'API',
+ lvl2: 'Foo',
+ lvl3: null,
+ lvl4: null,
+ lvl5: null
+ },
+ _highlightResult: {
+ hierarchy_camel: {
+ lvl0: {
+ value: 'Python',
+ matchLevel: 'full'
+ },
+ lvl1: {
+ value: 'API2',
+ matchLevel: 'full'
+ }
+ },
+ hierarchy: {
+ lvl0: {
+ value: 'Ruby'
+ },
+ lvl1: {
+ value: 'API'
+ }
+ }
+ }
+ }];
+
+ // When
+ let actual = DocSearch.formatHits(input);
+
+ // Then
+ expect(actual[0].category).toEqual('Python');
+ expect(actual[0].subcategory).toEqual('API2');
+ });
it('should use lvl2 as title', () => {
// Given
let input = [{