Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add Ability to Select a Search Pipeline in Comparison Tool #352

Merged
merged 13 commits into from
Jan 26, 2024
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
Loading