Skip to content

Translate Google like searches into SQL Server's CONTAINS(..) queries.

License

Notifications You must be signed in to change notification settings

rmacfadyen/RobertsFullTextSearch

Repository files navigation

Robert's Full Text Search

This library translates a Google like search query into an SQL Server CONTAINS(..) query. By default individual words are AND'd, unless an explicit OR is used. Quoted words means and exact match. Words prefixed with a minus sign are exclusions.

Exclude words from your search
Put - in front of a word you want to leave out. For example, jaguar speed -car
Search for an exact match
Put a word or phrase inside quotes. For example, "tallest building".
Combine searches
Put "OR" between each search query. For example, marathon OR race.

Example Queries

running
Return matchs that contain running, and any forms of running like ran, runs, or run.
running leaping
Return matches that contain both running and leaping, or any forms of of running or leaping.
"running leaping"
Return matchs that contain the exact phrase running leaping.
running +leaping
Return matchs that contain the both running and any form of running and the exact word leaping.
running -leaping
Return matches that contain running but not leaping, or any forms of of running or leaping.
running OR leaping
Return matches that either running or leaping or both of them, or any forms of of running or leaping.
run*
Return matches that contain words that start with exactly run.

Nonsense queries

Not all queries make sense.

-running
A query of all exclusionay terms returns an empty string.
[... stop words ...]
A stop word is a short common word that is ignored. Words like "the", "a", "an", "is" and so forth. A query that is all stop words returns an empty string.

Logical Operators

A B C means A and B and C. With matches containing all three ranked higher than matches with only 1 or 2 matches.

A B OR C D means A and (B or C) and D. Apparently this is intuitive for more people. It is confusing and seemingly wrong for people with programming experience.

A B -C means A AND B AND NOT C.

a b c d e f g h i j

a OR b c d e f g h i j = (a or b) and c and d...

a b OR c d OR e

About

Translate Google like searches into SQL Server's CONTAINS(..) queries.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published