Skip to content

Commit

Permalink
Update results to display non-source fields in search comparison tool (
Browse files Browse the repository at this point in the history
…opensearch-project#340)

* Update results to display fields property in addition to source

Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

* Return result bins to limited height

Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

* Add back space between entries

Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

---------

Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>
  • Loading branch information
nung22 authored Nov 29, 2023
1 parent c64b9f5 commit 8f1422d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ export const ResultGridComponent = ({
);
};

const getDlTmpl = (doc: IDocType) => {
const getDlTmpl = (doc: Document) => {
const sourceFields = Object.assign(doc._source, doc.fields);

return (
<div className="truncate-by-height">
<span>
<dl className="source truncate-by-height">
{_.toPairs(doc).map((entry: string[]) => {
{_.toPairs(sourceFields).map((entry: string[]) => {
return (
<span key={uniqueId('grid-dt-dd-')}>
<dt>{`${entry[0]}:`}</dt>
Expand Down Expand Up @@ -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,
})
);

Expand Down
1 change: 1 addition & 0 deletions public/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface Document {
_id: string;
_score: number;
_source: IDocType;
fields: IDocType;
}

export interface SearchResults {
Expand Down

0 comments on commit 8f1422d

Please sign in to comment.