filterDuplicateInnerHighlights(hits, type) {
    for (let hit of hits) {
      if (hit.inner_hits && hit.inner_hits[type] && hit.inner_hits[type].hits) {
        for (let innerHit of hit.inner_hits[type].hits.hits) {
          if (innerHit.highlight) {
            let seenHighlights = [];
            for (let key in innerHit.highlight) {
              innerHit.highlight[key] = innerHit.highlight[key].filter(highlight => {
                if (seenHighlights.indexOf(highlight) === -1) {
                  seenHighlights.push(highlight);
                  return true;
                } else {
                  return false;
                }
              });
            }
          }
        }
      }
    }
    return hits;
  }
// and the unprocessed one. This function filters the dupes from inner hits.
and the unprocessed one. This function filters the dupes from inner hits.
and the unprocessed one . This function filters the dupes from inner hits .
filterDuplicateInnerHighlights(hits, type) {
    for (let hit of hits) {
      if (hit.inner_hits && hit.inner_hits[type] && hit.inner_hits[type].hits) {
        for (let innerHit of hit.inner_hits[type].hits.hits) {
          if (innerHit.highlight) {
            let seenHighlights = [];
            for (let key in innerHit.highlight) {
              innerHit.highlight[key] = innerHit.highlight[key].filter(highlight => {
                if (seenHighlights.indexOf(highlight) === -1) {
                  seenHighlights.push(highlight);
                  return true;
                } else {
                  return false;
                }
              });
            }
          }
        }
      }
    }
    return hits;
  }
filterDuplicateInnerHighlights ( hits , type ) { for ( let hit of hits ) { if ( hit . inner_hits && hit . inner_hits [ type ] && hit . inner_hits [ type ] . hits ) { for ( let innerHit of hit . inner_hits [ type ] . hits . hits ) { if ( innerHit . highlight ) { let seenHighlights = [ ] ; for ( let key in innerHit . highlight ) { innerHit . highlight [ key ] = innerHit . highlight [ key ] . filter ( highlight => { if ( seenHighlights . indexOf ( highlight ) === - 1 ) { seenHighlights . push ( highlight ) ; return true ; } else { return false ; } } ) ; } } } } } return hits ; }
and the unprocessed one.
and the unprocessed one .