[jsword-devel] New Search Syntax

DM Smith dmsmith555 at yahoo.com
Sun Apr 24 19:12:04 MST 2005


I have implemented the new search syntax that I suggested in an earlier 
posting.

The basic change is that it allows the full expressiveness of Lucene's 
search syntax.
This has been extended with blur and range/passage.

I also added two more fields to Advanced Search. One to help with spelling.
The other to find words that have a common prefix (i.e. starts with).

Some notes on Lucene's search syntax:
OR: (to find verses that have either one word or another)
joseph || mary
joseph mary
joseph OR mary

AND: (to find verses with both words)
joseph && mary
+joseph +mary
joseph AND mary

NOT: (find verses with the first word but not the second)
joseph ! mary
joseph -mary
joseph NOT mary

Phrases: (Find an exact phrase)
"son of man"

Near: (Find words that are close to each other in a verse)
"son man"~5

(JSword exclusive) Near: (Find words that are in verses that are close 
to each other)
jesus ~5 david (finds verses containing jesus that are within 5 verses 
on either side of one containing david)
jesus ~ david (within 1 verse on either side)
There are two significant restrictions on ~ and ~n:
It can only be used one time in a search request.
It cannot be in a parenthetical statement. This splits the search 
request into two halves. It searches the left and the right separately 
and then joins them together.

(JSword exclusive) Range Within/Without/Also: (Find verses relative to a 
specified range of passages)
Within: +[mat 1-5, gen-lev]
    When used alone, it is no different than specifying a passage.
    When used with other words, it only returns verses in the range.
Without: -[mat 1-5, gen-lev]
    Cannot be used alone. Finds results outside of the specified passages.
Also: [mat 1-5, gen-lev]
There are three significant restrictions on these:
    They must be specified at the beginning of the search request.
    It can only be used once.
    They cannot be followed by AND, &&, OR, ||, NOT, !, -

Finding words that you don't know how to spell (This will make all kinds 
of strange guesses, so turn ranking on)
abemelek~

Finding words that start with the same letters
jes*

Finding words that start and end the same:
ho*e

Using parentheses for complicated expressions:
(joseph && mary) || (jesus && david) ! ("son man"~5 || "son god"~3)
Will find all verses with both joseph both mary and also verses with 
both jesus and david that don't have the words son and man within 5 of 
each other or son and god within 3 of each other.



More information about the jsword-devel mailing list