update
This commit is contained in:
@@ -38,13 +38,14 @@ export default function MainLayout() {
|
|||||||
useState<InstantMeiliSearchInstance>();
|
useState<InstantMeiliSearchInstance>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { meilisearchUrl, meilisearchToken } = selector;
|
const { meilisearchUrl, meilisearchToken, enableHybridSearch } = selector;
|
||||||
const { searchClient } = instantMeiliSearch(
|
const { searchClient } = instantMeiliSearch(
|
||||||
meilisearchUrl,
|
meilisearchUrl,
|
||||||
meilisearchToken,
|
meilisearchToken,
|
||||||
{
|
{
|
||||||
finitePagination: true,
|
finitePagination: true,
|
||||||
meiliSearchParams: {
|
meiliSearchParams: {
|
||||||
|
hybrid: enableHybridSearch ? ({} as any) : undefined,
|
||||||
attributesToRetrieve: [
|
attributesToRetrieve: [
|
||||||
"cover",
|
"cover",
|
||||||
"title",
|
"title",
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { ThemeSetting } from "@/component/Settings/Theme";
|
|||||||
import { disableSentry } from "@/sentry";
|
import { disableSentry } from "@/sentry";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { useOptionsState } from "@/store/module/options";
|
import { useOptionsState } from "@/store/module/options";
|
||||||
import { setMeilisearchToken, setMeilisearchUrl, setS3Url } from "@/store/reducer/options";
|
import { setEnableHybridSearch, setMeilisearchToken, setMeilisearchUrl, setS3Url } from "@/store/reducer/options";
|
||||||
import { useLocalStorage } from "@mantine/hooks";
|
import { useLocalStorage } from "@mantine/hooks";
|
||||||
import { IconBrandGithub, IconMail } from "@tabler/icons-react";
|
import { IconBrandGithub, IconMail } from "@tabler/icons-react";
|
||||||
import { Meilisearch } from "meilisearch";
|
import { Meilisearch } from "meilisearch";
|
||||||
@@ -110,6 +110,22 @@ export default function SettingsPage() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Enable Hybrid Search",
|
||||||
|
description: "Enable hybrid search for Meilisearch",
|
||||||
|
value: (
|
||||||
|
<div>
|
||||||
|
<Switch
|
||||||
|
size="md"
|
||||||
|
checked={options.enableHybridSearch}
|
||||||
|
onChange={(value) => {
|
||||||
|
const v = value.currentTarget.checked;
|
||||||
|
store.dispatch(setEnableHybridSearch(v));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export interface OptionsState {
|
|||||||
meilisearchUrl: string;
|
meilisearchUrl: string;
|
||||||
meilisearchToken: string;
|
meilisearchToken: string;
|
||||||
s3Url: string;
|
s3Url: string;
|
||||||
|
enableHybridSearch?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState: OptionsState = {
|
const initialState: OptionsState = {
|
||||||
@@ -11,6 +12,7 @@ const initialState: OptionsState = {
|
|||||||
meilisearchToken:
|
meilisearchToken:
|
||||||
"a568afad53a4dd124c508b9acd26ec35ff65665c07020913533cd7b176a28a04",
|
"a568afad53a4dd124c508b9acd26ec35ff65665c07020913533cd7b176a28a04",
|
||||||
s3Url: "https://minio-hdd.yoshino-s.xyz/",
|
s3Url: "https://minio-hdd.yoshino-s.xyz/",
|
||||||
|
enableHybridSearch: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const optionsSlice = createSlice({
|
const optionsSlice = createSlice({
|
||||||
@@ -26,10 +28,16 @@ const optionsSlice = createSlice({
|
|||||||
setS3Url: (state, action: PayloadAction<string | undefined>) => {
|
setS3Url: (state, action: PayloadAction<string | undefined>) => {
|
||||||
state.s3Url = action.payload ?? initialState.s3Url;
|
state.s3Url = action.payload ?? initialState.s3Url;
|
||||||
},
|
},
|
||||||
|
setEnableHybridSearch: (
|
||||||
|
state,
|
||||||
|
action: PayloadAction<boolean | undefined>
|
||||||
|
) => {
|
||||||
|
state.enableHybridSearch = action.payload ?? initialState.enableHybridSearch;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const { setS3Url, setMeilisearchUrl, setMeilisearchToken } =
|
export const { setS3Url, setMeilisearchUrl, setMeilisearchToken, setEnableHybridSearch } =
|
||||||
optionsSlice.actions;
|
optionsSlice.actions;
|
||||||
|
|
||||||
export default optionsSlice.reducer;
|
export default optionsSlice.reducer;
|
||||||
|
|||||||
Reference in New Issue
Block a user