Skip to content

Commit

Permalink
Merge pull request #646 from visualize-admin/feat/wildcard-search
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbrowne authored Aug 23, 2022
2 parents bedb219 + 2a006ed commit c8ccd42
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/components/debug-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ const DebugSearch = () => {
filters={[territoryTheme]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="bath"
filters={[territoryTheme]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
Expand Down
15 changes: 14 additions & 1 deletion app/rdf/query-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,19 @@ const makeVisualizeFilter = (includeDrafts: boolean) => {
`;
};

const enhanceQuery = (rawQuery: string) => {
return (
rawQuery
.toLowerCase()
.split(" ")
// Wildcard Searches on each term
.map((t) => `${t}*`)
.join(" ")
);
};

export const searchCubes = async ({
query,
query: rawQuery,
locale,
filters,
includeDrafts,
Expand All @@ -69,6 +80,8 @@ export const searchCubes = async ({
sparqlClient: ParsingClient;
sparqlClientStream: StreamClient;
}) => {
const query = rawQuery ? enhanceQuery(rawQuery) : undefined;

// Search cubeIris along with their score
const themeValues =
filters?.filter((x) => x.type === "DataCubeTheme").map((v) => v.value) ||
Expand Down

1 comment on commit c8ccd42

@vercel
Copy link

@vercel vercel bot commented on c8ccd42 Aug 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

visualization-tool – ./

visualization-tool-alpha.vercel.app
visualization-tool-git-main-ixt1.vercel.app
visualization-tool-ixt1.vercel.app

Please sign in to comment.