All Projects → 0b01 → autocompletex

0b01 / autocompletex

Licence: MIT License
redis autocomplete for elixir

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to autocompletex

Zsh Autocomplete
🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
Stars: ✭ 641 (+2813.64%)
Mutual labels:  autocomplete, completion, typeahead
react-native-autocomplete-dropdown
Dropdown Item picker with search and autocomplete (typeahead) functionality for react native
Stars: ✭ 87 (+295.45%)
Mutual labels:  autocomplete, typeahead
react-power-select
A highly composable & reusable select/autocomplete components
Stars: ✭ 63 (+186.36%)
Mutual labels:  autocomplete, typeahead
react-thailand-address-typeahead
jquery.Thailand.js in React
Stars: ✭ 78 (+254.55%)
Mutual labels:  autocomplete, typeahead
Autosuggest Highlight
Utilities for highlighting text in autosuggest and autocomplete components
Stars: ✭ 176 (+700%)
Mutual labels:  autocomplete, typeahead
Ng Select
⭐ Native angular select component
Stars: ✭ 2,781 (+12540.91%)
Mutual labels:  autocomplete, typeahead
indicium
🔎 A simple in-memory search for collections and key-value stores.
Stars: ✭ 41 (+86.36%)
Mutual labels:  autocomplete, typeahead
Autocomplete
🔮 Fast and full-featured autocomplete library
Stars: ✭ 1,268 (+5663.64%)
Mutual labels:  autocomplete, typeahead
instatype
⚡️ Mobile-friendly React autocomplete component
Stars: ✭ 48 (+118.18%)
Mutual labels:  autocomplete, typeahead
vue-thailand-address
🇹🇭 Thai address input for Vue.
Stars: ✭ 44 (+100%)
Mutual labels:  autocomplete, typeahead
vue-single-select
single select dropdown with autocomplete
Stars: ✭ 43 (+95.45%)
Mutual labels:  autocomplete, typeahead
React Autowhatever
Accessible rendering layer for Autosuggest and Autocomplete components
Stars: ✭ 146 (+563.64%)
Mutual labels:  autocomplete, typeahead
React Autocomplete Hint
A React component for Autocomplete Hint.
Stars: ✭ 131 (+495.45%)
Mutual labels:  autocomplete, typeahead
Autocomplete
Blazing fast and lightweight autocomplete widget without dependencies. Only 1KB gzipped. Demo:
Stars: ✭ 244 (+1009.09%)
Mutual labels:  autocomplete, typeahead
React Input Enhancements
Set of enhancements for input control
Stars: ✭ 1,375 (+6150%)
Mutual labels:  autocomplete, typeahead
bootstrap-5-autocomplete
autocomplete/typeahead js plugin for bootstrap v5
Stars: ✭ 79 (+259.09%)
Mutual labels:  autocomplete, typeahead
svelecte
Selectize-like component written in Svelte, also usable as custom-element 💪⚡
Stars: ✭ 121 (+450%)
Mutual labels:  autocomplete, typeahead
Bootstrap 4 Autocomplete
A simple autocomplete/typeahead for Bootstrap 4 and jQuery
Stars: ✭ 36 (+63.64%)
Mutual labels:  autocomplete, typeahead
Ngautocomplete
Light-weight autocomplete component for Angular.
Stars: ✭ 52 (+136.36%)
Mutual labels:  autocomplete, completion
react-abstract-autocomplete
Bring-Your-Own-UI autocomplete / mentions component for React.
Stars: ✭ 15 (-31.82%)
Mutual labels:  autocomplete, typeahead

Autocompletex

Coverage Status Build Status hex.pm

Autocompletex is a low-latency plug-and-play autocomplete tool using Redis sorted set. Written in pure Elixir, it focuses on rapid prototyping using your existing stack: simply start a redis instance, and start_link a GenServer.

Currently, it provides these implementation:

  • Google-like query prediction based on popularity. E.G. ne -> netflix, new york times
  • Lexicographic. Sorted in alphabetical order (faster)

There are two ways to run it:

  • Use it as a standalone microservice with HTTP connection.
  • GenServer

Installation

Add the :autocompletex to your mix.exs file:

def deps do
  [{:autocompletex, "~> 0.1.0"}]
end

Then add it to applications:

defp application() do
  [applications: [:logger, :autocompletex]]
end

Then, run mix deps.get in your shell to fetch the new dependency.

Usage

Overview

Currently, two types of autocompletion are supported:

  • Lexicographic
  • Predictive

If you want to suggest another scheme, please post an issue.

There are 3 ways to run it.

  1. Standalone HTTP service
  2. Using a GenServer
  3. Supervision tree

Manual

To start a GenServer manually:

# For Lexicographic:
{:ok, conn} = Redix.start_link
db = "testdb"
{:ok, worker} = Autocompletex.Lexicographic.start_link(conn, db, Autocompletex.Lexicographic)

# For Predictive:
{:ok, conn} = Redix.start_link
db_prefix = "autocompletex"
{:ok, worker} = Autocompletex.Predictive.start_link(conn, db_prefix, Autocompletex.Predictive)

Alternatively, you can use it in a supervision tree.

Add this to config.exs:

config :autocompletex,
  redis_host: "localhost",
  redis_port: 6379,
  redis_string: nil,
  http_server: true,
  http_port: 3000,
  debug: false, # runs :observer.start if true
  type: :lexicographic #:predictive

Then call

Autocompletex.Lexicographic.upsert(Autocompletex.Lexicographic, ["test", "example"])

If http_server is set to true, two http endpoints will be accessible at the designated http_port(default: 3000).

upsert   -> /add?term=Elixir
complete -> /complete?term=te

API

There are two functions: upsert and complete.

upsert/2 means insert or update. For Lexicographic, if a query is already inserted, it will do nothing. For Predictive, it will increment the score of the query.

complete/3 returns a list of matched results. It takes 3 parameters: pid, prefix, rangelen. rangelen is the number of results to be returned. Defaults to 50.

:ok = Autocompletex.Lexicographic.upsert(worker, ["test", "example"])
{:ok, val} == complete(worker, "te") # assert val == ["test"]

Misc

Import file into Redis

If you have a list of user-generated search queries, you can use a mix task to index and provision the redis instance.

Simply do:

mix autocompletex.import --filename [path/to/file] [--predictive]

Internals

For predictive autocompletion, this tool will create keys [dbname]:[prefixes] as sorted sets. For example, for dbname autocompletex, word test:

autocompletex:t
autocompletex:te
autocompletex:tes

For lexicographic autocompletion, under sorted set [dbname].

Docs

To be updated. In the meantime, I'm happy to answer questions in issues.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].