Skip to content

Commit df1df69

Browse files
jamal-kheySlimane AMAR
andauthored
implement scoring for directory elements (#461)
add scoring in ElasticSearch queries using path and parent ID --------- Signed-off-by: jamal-khey <[email protected]> Co-authored-by: Slimane AMAR <[email protected]>
1 parent d0b97b1 commit df1df69

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/components/search/search-bar.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ interface SearchBarProps {
3838
inputRef: RefObject<TextFieldProps>;
3939
}
4040

41-
const fetchElements: (newSearchTerm: string) => Promise<ElementAttributesES[]> =
42-
searchElementsInfos;
43-
4441
export const SearchBar: FunctionComponent<SearchBarProps> = ({ inputRef }) => {
4542
const dispatch = useDispatch();
4643
const { snackError } = useSnackMessage();
@@ -51,6 +48,14 @@ export const SearchBar: FunctionComponent<SearchBarProps> = ({ inputRef }) => {
5148
);
5249
treeDataRef.current = treeData;
5350

51+
const fetchElements: (
52+
newSearchTerm: string
53+
) => Promise<ElementAttributesES[]> = useCallback(
54+
(newSearchTerm) =>
55+
searchElementsInfos(newSearchTerm, selectedDirectory?.elementUuid),
56+
[selectedDirectory?.elementUuid]
57+
);
58+
5459
const { elementsFound, isLoading, searchTerm, updateSearchTerm } =
5560
useElementSearch({
5661
fetchElements,

src/utils/rest-api.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,13 +823,14 @@ export const getExportFormats = () => {
823823
return backendFetchJson(url);
824824
};
825825

826-
export function searchElementsInfos(searchTerm) {
826+
export function searchElementsInfos(searchTerm, currentDirectoryUuid) {
827827
console.info(
828828
"Fetching elements infos matching with '%s' term ... ",
829829
searchTerm
830830
);
831831
const urlSearchParams = new URLSearchParams();
832832
urlSearchParams.append('userInput', searchTerm);
833+
urlSearchParams.append('directoryUuid', currentDirectoryUuid);
833834
return backendFetchJson(
834835
PREFIX_DIRECTORY_SERVER_QUERIES +
835836
'/v1/elements/indexation-infos?' +

0 commit comments

Comments
 (0)