Skip to content

Commit

Permalink
Feature: Add Ability to Select a Search Pipeline in Comparison Tool (#…
Browse files Browse the repository at this point in the history
…352)

* Add search pipeline parameters to index and route files

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

* Add search pipeline dropdown

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

* Integrate option to select search pipeline

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

* Update tests and snapshots

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

* Update get pipelines endpoint

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

* Update .babelrc

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

* Update test snapshots

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

* Add id attribute to search bar (#338)

* Add id to search bar

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

* Add keys to getDlTmpl component

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

* Change enclosing tag to span instead of div

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

---------

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

* Update .babelrc

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

* Add ability to select _none option

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

* Update test coverages

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

* Update variables in pipeline selection

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

---------

Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>
  • Loading branch information
nung22 authored Jan 26, 2024
1 parent c2f175b commit 29e5867
Show file tree
Hide file tree
Showing 13 changed files with 1,411 additions and 408 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
["@babel/plugin-transform-runtime", { "regenerator": true }]
]
}

3 changes: 3 additions & 0 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export const PLUGIN_NAME = 'Search Relevance';

export enum ServiceEndpoints {
GetIndexes = '/api/relevancy/search/indexes',
GetPipelines = '/api/relevancy/search/pipelines',
GetSearchResults = '/api/relevancy/search',
GetStats = '/api/relevancy/stats',
}

export const SEARCH_API = '/_search';
18 changes: 13 additions & 5 deletions public/components/query_compare/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import React, { useEffect } from 'react';
import { NavigationPublicPluginStart } from 'src/plugins/navigation/public';
import { NavigationPublicPluginStart } from '../../../../../src/plugins/navigation/public';
import { CoreStart, ChromeBreadcrumb } from '../../../../../src/core/public';
import '../../ace-themes/sql_console';
import { CreateIndex } from './create_index';
Expand All @@ -25,7 +25,6 @@ interface QueryExplorerProps {
setToast: (title: string, color?: string, text?: any, side?: string) => void;
chrome: CoreStart['chrome'];
}

export const Home = ({
parentBreadCrumbs,
notifications,
Expand All @@ -35,19 +34,28 @@ export const Home = ({
setToast,
chrome,
}: QueryExplorerProps) => {
const { documentsIndexes, setDocumentsIndexes, showFlyout } = useSearchRelevanceContext();
const {
documentsIndexes,
setDocumentsIndexes,
pipelines,
setPipelines,
showFlyout,
} = useSearchRelevanceContext();

useEffect(() => {
setBreadcrumbs([...parentBreadCrumbs]);
}, [setBreadcrumbs, parentBreadCrumbs]);

// Get Indexes
// Get Indexes and Pipelines
useEffect(() => {
http.get(ServiceEndpoints.GetIndexes).then((res: DocumentsIndex[]) => {
setDocumentsIndexes(res);
});
}, [http, setDocumentsIndexes]);

http.get(ServiceEndpoints.GetPipelines).then((res: {}) => {
setPipelines(res);
});
}, [http, setDocumentsIndexes, setPipelines]);
return (
<>
<div className="osdOverviewWrapper">
Expand Down
7 changes: 6 additions & 1 deletion public/components/query_compare/search_result/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const SearchResult = ({ http }: SearchResultProps) => {
updateComparedResult2,
selectedIndex1,
selectedIndex2,
pipeline1,
pipeline2,
} = useSearchRelevanceContext();

const onClickSearch = () => {
Expand Down Expand Up @@ -86,6 +88,7 @@ export const SearchResult = ({ http }: SearchResultProps) => {
const handleQuery = (
queryError: QueryError,
selectedIndex: string,
pipeline: string,
jsonQuery: any,
updateComparedResult: (result: SearchResults) => void,
setQueryResult: React.Dispatch<React.SetStateAction<SearchResults>>,
Expand All @@ -97,7 +100,7 @@ export const SearchResult = ({ http }: SearchResultProps) => {
updateComparedResult({} as any);
} else if (!queryError.queryString.length && !queryError.selectIndex) {
setQueryError(initialQueryErrorState);
return { index: selectedIndex, ...jsonQuery };
return { index: selectedIndex, pipeline, ...jsonQuery };
}
};

Expand All @@ -106,6 +109,7 @@ export const SearchResult = ({ http }: SearchResultProps) => {
query1: handleQuery(
queryErrors[0],
selectedIndex1,
pipeline1,
jsonQueries[0],
updateComparedResult1,
setQueryResult1,
Expand All @@ -114,6 +118,7 @@ export const SearchResult = ({ http }: SearchResultProps) => {
query2: handleQuery(
queryErrors[1],
selectedIndex2,
pipeline2,
jsonQueries[1],
updateComparedResult2,
setQueryResult2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ const InitialState = () => {
<EuiEmptyPrompt
iconType="search"
title={<h2>No results</h2>}
body={
<p>Add at least one query to display search results.</p>
}
body={<p>Add at least one query to display search results.</p>}
/>
</EuiPanel>
);
Expand Down
Loading

0 comments on commit 29e5867

Please sign in to comment.