Search API with spelling correction using ngram-index algorithm: implementation using Java Spring-boot and MySQL ngram full text search index

Overview

Search API to handle Spelling-Corrections

Based on N-gram index algorithm: using MySQL Ngram Full-Text Parser

Sample Screen-Recording

Screen.Recording.2021-10-21.at.1.20.43.PM.mov

Tech stack

  • MySQL Ngram Text Parser (REFERENCE)
  • EntityManager (JpaRepository can also be used)
  • Flyway
  • Spring-boot to expose REST API

Important files

Customizing response through score values

ngram index algorithm computes scores for every record in accordance with the provided keyword. Below attached is a sample screenshot to show the results (look at the score column)

Screenshot 2021-10-21 at 6 43 37 PM

Depending on the usecase in front and functionality to be achieved by a particular application, we can put a condition in our native sql query to return only those records which have a computed score greater than {value-needed: example 1.5, 0.7 etc}

Attaching sample query

SELECT id, name, bio,
    MATCH(name,bio) 
    AGAINST('James Potter') as score
FROM characters 
WHERE 
    MATCH(name,bio) 
    AGAINST('James Potter') >1.4 ORDER BY score DESC;

Screenshot 2021-10-21 at 6 52 41 PM

The count of the data was reduced significantly just by introducing the greater than score condition We can even make the value dynamic depending upon the size of records being matched or have the frontend provide the value using request-parameter to the API

Local Setup

  • Install Java 17 (recommended to use SdkMan)

sdk install java 17-open

  • Install Maven (recommended to use SdkMan)

sdk install maven

  • Clone the repo and configure datasource values in the application.properties file, run the below command

mvn clean install

  • To start the application

mvn spring-boot:run &

  • Access the sole API on below path(s)

    • to view all character records
    http://localhost:8080/characters
    
    • to view character records based on a searchable keyword (page starts from index 1 and count is set to 10 of no count param is provided)
    http://localhost:8080/characters?keyword=harry&count=20&page=1
    
You might also like...

Full Stack Employee Management Application Using ReactJS and Spring Boot

Full Stack Employee Management Application Using ReactJS and Spring Boot Tech We Used ReactJs Spring Boot MySql Database Spring Security REST API Feat

Nov 18, 2022

A high availability shopping(ecommerce) system using SpringBoot, Spring Cloud, Eureka Server, Spring Cloud Gateway, resillience4j, Kafka, Redis and MySQL.

A high availability shopping(ecommerce) system using SpringBoot, Spring Cloud, Eureka Server, Spring Cloud Gateway, resillience4j, Kafka, Redis and MySQL.

High-availability-shopping-system A high availability shopping(ecommerce) system using SpringBoot, Spring Cloud, Eureka Server, Spring Cloud Gateway,

Oct 26, 2022

Spring Boot JdbcTemplate example with SQL Server: CRUD Rest API using Spring Data JDBC, Spring Web MVC

Spring Boot JdbcTemplate example with SQL Server: Build CRUD Rest API Build a Spring Boot CRUD Rest API example that uses Spring Data Jdbc to make CRU

Dec 20, 2022

Facsimile - Copy Your Most Used Text to Clipboard Easily with Facsimile!. It Helps You to Store You Most Used Text as a Key, Value Pair and Copy it to Clipboard with a Shortcut.

Facsimile - Copy Your Most Used Text to Clipboard Easily with Facsimile!. It Helps You to Store You Most Used Text as a Key, Value Pair and Copy it to Clipboard with a Shortcut.

Facsimile An exact copy of Your Information ! Report Bug · Request Feature Table of Contents About The Project Built With Getting Started Installation

Sep 12, 2022

一个基于vue3.0+antd+less+spring boot +mybatis+mysql+maven基础权限管理平台

一个基于vue3.0+antd+less+spring boot +mybatis+mysql+maven基础权限管理平台

cc-project vue 版本 angular版本请到 https://github.com/myopenresources/cc-project 这里看 详细文档 请到 cc-project详细文档 介绍 cc-project-vue 是一个前后端分离的项目,前端使用的是vue3.0,后端使用

Jun 23, 2022

Spring Boot Simple Login & Registration + MyBatis + MySQL

springboot-mybatis-security-login-register A simple security login & registration module using Spring Boot, Spring Security, MyBatis Framework and MyS

May 31, 2022

ProxySql, MySQL Replication, Spring Boot

ProxySql, MySQL Replication, Spring Boot

MySQL Replication with ProxySQL In this documentation, we will cover Problem Discussion Common Database problems and solutions. What is Database Repli

Dec 23, 2022

A simple blog post api made with spring,mysql.Following tutorial by @FadatareRamesh(Java Guides)

blogAPI A simple blog post api made with spring,mysql.Following tutorial by @FadatareRamesh(Java Guides) Frontend server(made using Angular) can be fo

Feb 2, 2022

The Spring Boot Sample App on K8S has been implemented using GKE K8S Cluster, Spring Boot, Maven, and Docker.

gke-springboot-sampleapp 👋 The Spring Boot Sample App on K8S has been implemented using GKE K8S Cluster, Spring Boot, Maven, and Docker. Usage To be

Feb 1, 2022
Owner
Hardik Singh Behl
Java Web Developer
Hardik Singh Behl
该仓库中主要是 Spring Boot 的入门学习教程以及一些常用的 Spring Boot 实战项目教程,包括 Spring Boot 使用的各种示例代码,同时也包括一些实战项目的项目源码和效果展示,实战项目包括基本的 web 开发以及目前大家普遍使用的线上博客项目/企业大型商城系统/前后端分离实践项目等,摆脱各种 hello world 入门案例的束缚,真正的掌握 Spring Boot 开发。

Spring Boot Projects 该仓库中主要是 Spring Boot 的入门学习教程以及一些常用的 Spring Boot 实战项目教程,包括 Spring Boot 使用的各种示例代码,同时也包括一些实战项目的项目源码和效果展示,实战项目包括基本的 web 开发以及目前大家普遍使用的前

十三 4.5k Dec 30, 2022
循序渐进,学习Spring Boot、Spring Boot & Shiro、Spring Batch、Spring Cloud、Spring Cloud Alibaba、Spring Security & Spring Security OAuth2,博客Spring系列源码:https://mrbird.cc

Spring 系列教程 该仓库为个人博客https://mrbird.cc中Spring系列源码,包含Spring Boot、Spring Boot & Shiro、Spring Cloud,Spring Boot & Spring Security & Spring Security OAuth2

mrbird 24.8k Jan 6, 2023
Document scanner with border detection, perspective correction and custom crop/resize

react-native-document-scanner Preview iOS Android Both Platform Use version >=1.4.1 if you are using react-native 0.48+ $ yarn add https://github.com/

Augusto Pinheiro 53 Nov 10, 2022
Spring Boot OAuth 2.0 Client Implementation + MySQL Integration

Spring Boot OAuth 2.0 Client + MySQL 1. What is OAuth 2.0 ? The OAuth 2.0 authorization framework enables a third-party application to obtain limited

Salah Eddine Zemmouri 8 May 12, 2022
Presti 5 Nov 19, 2022
Java implementation of Beacon Chain for Ethereum 2.0, and its Backend API and full Infrastructure.

hailong Implementation of the Ethereum 2.0 Beacon Chain. Based on the (evolving) specification. Build Instructions Install Prerequisites 1) Java 11 Ub

我是高天才! 14 Feb 6, 2022
开源论坛、问答系统,现有功能提问、回复、通知、最新、最热、消除零回复功能。功能持续更新中…… 技术栈 Spring、Spring Boot、MyBatis、MySQL/H2、Bootstrap

码问社区 在线演示地址 www.mawen.co 功能列表 开源论坛、问答系统,现有功能提问、回复、通知、最新、最热、消除零回复功能。功能持续更新中…… 技术栈 技术 链接 Spring Boot http://projects.spring.io/spring-boot/#quick-start

小匠 2.3k Dec 30, 2022
This project contains a full example of an application developed using Spring Boot and GraphQL within the Java.

Spring boot GraphQL Example This project contains a full example of an application developed using GraphQL within the Java. The project includes a com

Haoqiao Wang 3 Jul 20, 2022
Text to Speech Project for Spring Boot and Kotlin, Auth Server, Python with Fast API (gTTS)

TTS-App Text to Speech Project for Spring Boot Module (etc Resource, Auth Server, Python with Fast API (gTTS)) Python의 gTTS lib를 활용하여 텍스트를 음성으로 변환하는 서

Seokhyun 7 Dec 21, 2021
In this course, we will learn how to build a complete full-stack web application using Spring boot as backend and React (React Hooks) as frontend

In this course, we will learn how to build a complete full-stack web application using Spring boot as backend and React (React Hooks) as frontend. We will use MySQL database to store and retrieve the data.

Ramesh Fadatare 43 Dec 22, 2022