-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace fulltext with search service
- Loading branch information
1 parent
bcd3eb2
commit cbc2e9a
Showing
15 changed files
with
115 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { searchApiPost } from './host'; | ||
import { Concept, SearchObject } from '../../types'; | ||
|
||
export const searchConcepts = (body: any) => | ||
searchApiPost('/search/concepts', body); | ||
|
||
const mapFilters = ({ uri }: any) => { | ||
if (uri) { | ||
return { uri: { value: uri } }; | ||
} | ||
|
||
return undefined; | ||
}; | ||
|
||
export const paramsToSearchBody = ({ q, ...params }: any) => { | ||
const body = { | ||
query: q, | ||
filters: mapFilters(params) | ||
}; | ||
return body; | ||
}; | ||
|
||
export const extractConcepts = (searchResponse: any): Promise<SearchObject[]> => | ||
searchResponse?.hits ?? []; | ||
|
||
export const extractInternalConcepts = ( | ||
searchResponse: any | ||
): Promise<Concept[]> => searchResponse?.hits ?? []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import axios from 'axios'; | ||
import cleanDeep from 'clean-deep'; | ||
import { getConfig } from '../../config'; | ||
|
||
interface Props { | ||
path: string; | ||
method: any; | ||
params?: any; | ||
data?: any; | ||
} | ||
|
||
export const searchApi = ({ path, method, params, data }: Props) => | ||
axios({ | ||
url: `${getConfig().searchApi.host}${path}`, | ||
method, | ||
params, | ||
data | ||
}) | ||
.then(response => cleanDeep(response.data)) | ||
.catch(() => null); | ||
|
||
export const searchApiPost = (path: string, body: any) => | ||
searchApi({ path, method: 'POST', data: body }); | ||
|
||
export const searchApiGet = (path: string, params: any) => | ||
searchApi({ path, method: 'GET', params }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { searchApiGet } from './host'; | ||
import { SearchObject } from '../../types'; | ||
|
||
export const extractSuggestions = ( | ||
searchResponse: any | ||
): Promise<SearchObject[]> => searchResponse.suggestions ?? []; | ||
|
||
export const getConceptSuggestions = (params: any) => | ||
searchApiGet('/suggestions/concepts', params); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.