Skip to content

Commit

Permalink
history
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonStoltz committed Oct 14, 2021
1 parent 9f07f71 commit 537cfc0
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React from 'react';
import React, { useState } from 'react';
import { useParams } from 'react-router-dom';

import { useValues, useActions } from 'kea';
Expand All @@ -14,6 +14,7 @@ import { EuiButton, EuiBadge, EuiLoadingSpinner, EuiFlexGroup, EuiFlexItem } fro

import { AppSearchPageTemplate } from '../../layout';
import { AutomatedIcon } from '../components/automated_icon';

import {
AUTOMATED_LABEL,
COVERT_TO_MANUAL_BUTTON_LABEL,
Expand All @@ -26,26 +27,37 @@ import { HIDDEN_DOCUMENTS_TITLE, PROMOTED_DOCUMENTS_TITLE } from './constants';
import { CurationLogic } from './curation_logic';
import { DeleteCurationButton } from './delete_curation_button';
import { PromotedDocuments, OrganicDocuments } from './documents';
import { History } from './history';

const PROMOTED = 'promoted';
const HISTORY = 'history';

export const AutomatedCuration: React.FC = () => {
const { curationId } = useParams<{ curationId: string }>();
const logic = CurationLogic({ curationId });
const { convertToManual } = useActions(logic);
const { activeQuery, dataLoading, queries, curation } = useValues(logic);
const [selectedPageTab, setSelectedPageTab] = useState(PROMOTED);

// This tab group is meant to visually mirror the dynamic group of tags in the ManualCuration component
const pageTabs = [
{
label: PROMOTED_DOCUMENTS_TITLE,
append: <EuiBadge>{curation.promoted.length}</EuiBadge>,
isSelected: true,
isSelected: selectedPageTab === PROMOTED,
onClick: () => setSelectedPageTab(PROMOTED),
},
{
label: HIDDEN_DOCUMENTS_TITLE,
append: <EuiBadge isDisabled>0</EuiBadge>,
isSelected: false,
disabled: true,
},
{
label: 'History',
isSelected: selectedPageTab === HISTORY,
onClick: () => setSelectedPageTab(HISTORY),
},
];

return (
Expand Down Expand Up @@ -83,8 +95,9 @@ export const AutomatedCuration: React.FC = () => {
}}
isLoading={dataLoading}
>
<PromotedDocuments />
<OrganicDocuments />
{selectedPageTab === PROMOTED && <PromotedDocuments />}
{selectedPageTab === PROMOTED && <OrganicDocuments />}
{selectedPageTab === HISTORY && <History query={curation.queries[0]} />}
</AppSearchPageTemplate>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';

import { LogStream } from '../../../../../../../infra/public';
import { EntSearchLogStream } from '../../../../shared/log_stream';

interface Props {
query: string;
}

export const History: React.FC<Props> = ({ query }) => {
return (
<div>
<EntSearchLogStream
hoursAgo={720}
query={`appsearch.search_relevance_suggestions.query: ${query} and event.kind: event and event.dataset: search-relevance-suggestions`}
columns={[
{ type: 'timestamp' },
{
type: 'field',
field: 'appsearch.search_relevance_suggestions.query',
header: 'Query',
},
{
type: 'field',
field: 'event.type',
header: 'Event type',
},
{
type: 'field',
field: 'appsearch.search_relevance_suggestions.suggestion.new_status',
header: 'Status',
},
{
type: 'field',
field: 'appsearch.search_relevance_suggestions.suggestion.curation.promoted_docs',
header: 'Promoted documents',
},
]}
/>
</div>
);
};
8 changes: 8 additions & 0 deletions x-pack/plugins/enterprise_search/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ export class EnterpriseSearchPlugin implements Plugin {
indexName: '.ent-search-*',
},
});

infra.defineInternalSourceConfiguration('suggestions', {
name: 'Enterprise Search relevance suggestion logs',
logIndices: {
type: 'index_name',
indexName: '.ent-search-search-relevance-suggestions-ecs*',
},
});
}

public start() {}
Expand Down

0 comments on commit 537cfc0

Please sign in to comment.