Lucene search

Previous  Next |  Direct link to this topic

NB: Lucene Search is  in legacy mode and is hidden in installations there does not have it turned on. Lucene Search will be maintained but will not provide new features in the future.

 

Lucene is a high-performance, full-featured text search engine.

We have included Lucene with our B1UP server component enabling B1 Search to perform high-performance text search.

 

The benefit of using Lucene search:

Better performance and faster search results

More accurate search results

Support for wildcard, boolean operators and fuzzy search

 

Requirements

Lucene search requires MSSQL 2012 or higher/SAP HANA.

Enable Lucene in the B1UP server component

Enable it pr. database that should use Lucene search

Wait for the first time indexing to be finished

 

How does it work?

Lucene creates an index version of the SAP Business One database. Only documents supported by B1 Search are indexed. Each document type (Example A/R Invoice) is index and fields are ranked by importance. As an example the CardCode and CardName fields rank higher than the comment field. This allows Lucene to return prioritize some fields higher when performing the search leading to better search results.
 
To keep the search index in sync with the SAP Business One database we modify the SAP Stored Procedure: "SBO_SP_PostTransactionNotice" to notify us of changes to the document types that we support. Based on the events we then update the index to reflect the changes in the database.
If you decide to not use Lucene after having it enabled we recommend removing the modification in the SBO_SP_PostTransactionNotice.

 

Usage

Lucene will automatically be used if enabled when using B1 Search.
The only noticeable difference is faster and more accurate search results. The rest of B1 Search works in the same way.

 
When Lucene is used you have the option to create queries that improves the search result directly in the B1 search field.

Query syntax

Feature

Description

Terms

A search query when entered into B1 Search is broken up into terms and operators. There are two types of terms: Single Terms and Phrases.

 
A Single Term is a single word such as "Maxi-Teq" or "Parameter".

 

A Phrase is a group of words surrounded by double quotes such as "Parameter Technology".

 

Multiple terms can be combined together with Boolean operators to form a more complex query.

Fields:

Lucene supports searching in SAP fields that have been included in the indexing.

You can search a field by typing the field name followed by a colon ":" and then the term you are looking for.

 

As an example, you can search for specific combination of ItemCode and CardName:

 

clip0068

The fields names matches what is stored in the database.

Wildcard Searches

Lucene supports single and multiple character wildcard searches within single terms (not within phrase queries).

 

To perform a single character wildcard search use the "?" symbol.

To perform a multiple character wildcard search use the "*" symbol.

 

The single character wildcard search looks for terms that match that with the single character replaced. For example, to search for "text" or "test" you can use the search:

 te?t

 

Multiple character wildcard searches looks for 0 or more characters. For example, to search for test, tests or tester, you can use the search:

 test*

 

You can also use the wildcard searches in the middle of a term.

 te*t

 
Note: You cannot use a * or ? symbol as the first character of a search.

 

Fuzzy Searches

Lucene supports fuzzy searches. To do a fuzzy search use the tilde, "~", symbol at the end of a Single word Term. For example to search for a term similar in spelling to "roam" use the fuzzy search:

 roam~

This search will find terms like foam and roams.

Boolean Operators

Boolean operators allow terms to be combined through logic operators.
Lucene supports AND, "+", OR, NOT and "-" as Boolean operators
 
Note: Boolean operators must be ALL CAPS.

 

OR

To search for documents that contain either "maxi-teq" or just "maxi" use the query:

 "maxi-teq" OR "maxi"

 
AND

The AND operator matches documents where both terms exist anywhere in the text of a single document.

To search for documents that contain "maxi-teq" and "A10000" use the query:

 "maxi-teq" AND "A10000"

 

+

The "+" or required operator requires that the term after the "+" symbol exist somewhere in a the field of a single document.

To search for documents that must contain "maxi" and may contain "A10000" use the query:

 +maxi A10000

 

NOT

The NOT operator excludes documents that contain the term after NOT.

To search for documents that contain "maxi-teq" but not "A10000" use the query:

 "maxi-teq" NOT "A10000"

 
Note: The NOT operator cannot be used with just one term. For example, the following search will return no results:

 NOT "maxi-teq"

Grouping

Lucene supports using parentheses to group clauses to form sub queries. This can be very useful if you want to control the boolean logic for a query.

To search for either "maxi" or "parameter" and "A10000" use the query:

 (maxi OR parameter) AND A10000

Escaping Special Characters

Lucene supports escaping special characters that are part of the query syntax. The current list special characters are

+ - && || ! ( ) { } [ ] ^ " ~ * ? : \

To escape these character use the \ before the character. For example to search for (1+1):2 use the query:

 \(1\+1\)\:2