PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, May 18, 2022

[FIXED] What is a good database platform designed for partial string matching in Java?

 May 18, 2022     database, java, partial, search, text     No comments   

Issue

I apologize if this question seems a bit general, but I've been Googling around to no avail and I'm not sure where else to go.

I've got a SQLite database in java that stores a lot of song title/artist names. Currently I'm querying the database like this:

SELECT * FROM music WHERE (title LIKE "%adio%" OR artist LIKE "%adio%") ORDER BY title, ASC LIMIT 20

Obviously this method is fairly slow because I use a wildcard on each side of the search term.

The thing is, if I search for "Radioactive" in iTunes, I can search "adio" and Radioactive pops up fairly quickly. What kind of database accomplishes this searching so quickly? I've looked into FTS in SQLite, but that doesn't allow for prefixed wildcards. I have a feeling SQLite isn't the correct choice here so I'm looking for suggestions. Thanks for your time!


Solution

Many relational databases have support for a feature called "Full Text Search" (FTS), which is what you are looking for.
FTS is a special kind of index that makes word searches fast. The syntax for FTS queries depends on the database (it is not standard like SQL). FTS indexes can be language specific which allows searches for similar words, synonyms, plural/singular in addition to exact word and prefix/suffix searches.
If you are looking for a non commercial option Postgres supports FTS.

But it really depends on your application. You might be better of with a non relational database. Take a look a Lucene for a stand alone full text search index, or at Elastic which is build on top of Lucene.

Most databases and certainly common ones can be accessed using Java, so that is not a concern when choosing a solution.



Answered By - Eli Algranti
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing