New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nanosearch

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanosearch

Build a search engine from a website sitemap.

  • 0.1.2
  • PyPI
  • Socket score

Maintainers
1

nanosearch

Nanosearch is an in-memory search engine designed for small (< 10,000 URL) websites.

With Nanosearch, you can build a search engine in a few lines of code.

Nanosearch supports the BM25 and TF/IDF algorithms.

Nanosearch also computes a link graph and uses the number of inlinks to a page as a ranking factor. This is useful for ranking results for queries where there are multiple relevant pages by keyword.

Installation

pip install nanosearch

Quickstart

Build a Search Engine from a Sitemap

from nanosearch import NanoSearchBM25

engine = NanoSearchBM25().from_sitemap(
    "https://jamesg.blog/sitemap.xml",
    title_transforms=[lambda x: x.split("|")[0]]
)
results = engine.search("coffee")

print(results)

Build a Search Engine from a List of URLs

from nanosearch import NanoSearchBM25

urls = [
    "https://jamesg.blog/",
    "https://jamesg.blog/coffee",
]

engine = NanoSearchBM25().from_urls(urls)
results = engine.search("coffee")

print(results)

Save an Index to Disk

You can save an index to disk and load it later with:

engine.to_nanosearch_json("index.json")

engine = NanoSearchBM25().from_nanosearch_json("index.json")

Supported Algorithms

Nanosearch supports the following search algorithms:

  • TF/IDF
  • BM25

License

This project is licensed under an MIT license.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc