Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Search with elasticsearch and facets #57

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

amitaibu
Copy link
Owner

#50

@amitaibu
Copy link
Owner Author

I get an error when running locally. I have a case where using Overmind causes devenv up to exit, vs. using the default, which still has ES failing but doesn't kill the process.

Overmind Default
image image

Comment on lines +17 to +21
# Allow unfree packages
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
};
Copy link
Owner Author

Choose a reason for hiding this comment

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

That's how Claude AI told me to do it

@amitaibu
Copy link
Owner Author

Update: We are now able to index the title and body of News

For now, we can see the results in http://localhost:9200/news/_search?pretty

image

@amitaibu
Copy link
Owner Author

To test:

  1. Go to http://localhost:8000/News, and add News
  2. Visit http://localhost:9200/news/_search?pretty
  3. Next is to understand how to parse the result

@amitaibu
Copy link
Owner Author

Took me more time than I'm willing to admit, but I was able to get the News ID from Elastic 😅

result <- parseEsResponse response
case result of
Left esError -> do
-- Handle the error (log it, return empty list, or throw an exception)
liftIO $ putStrLn $ "Error occurred: " ++ show esError
return []
Right (searchResult :: SearchResult Value) -> do
-- Extract the News IDs from the search result
let newsIds :: [Id News] = map (textToId . unDocId . hitDocId) $ hits $ searchHits searchResult
liftIO $ putStrLn $ "newsIds: " ++ show newsIds
return newsIds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant