From 8f1422d4bf55fcf6bee42e27dff1465af555c071 Mon Sep 17 00:00:00 2001 From: Nicholas Ung Date: Wed, 29 Nov 2023 14:36:52 -0800 Subject: [PATCH] Update results to display non-source fields in search comparison tool (#340) * Update results to display fields property in addition to source Signed-off-by: Nicholas Ung * Return result bins to limited height Signed-off-by: Nicholas Ung * Add back space between entries Signed-off-by: Nicholas Ung --------- Signed-off-by: Nicholas Ung --- .../search_result/result_components/result_grid.tsx | 10 ++++++---- public/types/index.ts | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/public/components/query_compare/search_result/result_components/result_grid.tsx b/public/components/query_compare/search_result/result_components/result_grid.tsx index 64f8207..3278c1e 100644 --- a/public/components/query_compare/search_result/result_components/result_grid.tsx +++ b/public/components/query_compare/search_result/result_components/result_grid.tsx @@ -44,12 +44,14 @@ export const ResultGridComponent = ({ ); }; - const getDlTmpl = (doc: IDocType) => { + const getDlTmpl = (doc: Document) => { + const sourceFields = Object.assign(doc._source, doc.fields); + return (
- {_.toPairs(doc).map((entry: string[]) => { + {_.toPairs(sourceFields).map((entry: string[]) => { return (
{`${entry[0]}:`}
@@ -165,11 +167,11 @@ export const ResultGridComponent = ({ cols.push(getRankColumn(document._id, documentRank)); // No field is selected - const _sourceLikeDOM = getDlTmpl(document._source); + const _sourceFieldsLikeDOM = getDlTmpl(document); cols.push( getTdTmpl({ clsName: fieldClsName, - content: _sourceLikeDOM, + content: _sourceFieldsLikeDOM, }) ); diff --git a/public/types/index.ts b/public/types/index.ts index 7ea4f43..d610015 100644 --- a/public/types/index.ts +++ b/public/types/index.ts @@ -24,6 +24,7 @@ export interface Document { _id: string; _score: number; _source: IDocType; + fields: IDocType; } export interface SearchResults {