Understanding how a search limit is evaluated
When you create optional and enforced search limits, they are evaluated during the data source indexing. A search limit evaluation makes comparisons between expression values in the search limit and the values in the specified search field or fields in a data source document, according to the operator used. When the search limit is evaluated during indexing, a comparison result of TRUE or FALSE is associated with each record in the index for that search limit.
When a patron performs a search, and a search limit is applied to the search either by the patron or automatically by the administrator, only the records that have the value of TRUE for the search limit are returned in the search results. By evaluating search limits during indexing, each record is evaluated only once instead of being evaluated every time a patron does a search. This single evaluation of records results in greater searching performance.
|
Since the value of TRUE or FALSE is assigned to each record in the search data source only when the records are indexed, you must index the records any time a search limit is added or a search limit expression is modified. If the search limit expression contains search fields that do not apply to a data source (for example, the LIBRARY field is not valid for PDF files), the data source does not need to be indexed for a new search limit or a modified search expression. |
The following list gives the rules that are used to determine the Boolean value that is returned by the search limit evaluation during the data source indexing.
- If the operator in the search limit expression is the string operator “contains,” “does not contain,” or “begins with,” any letters in the expression value(s) and search field value(s) are converted to uppercase letters before the search limit evaluation begins. For example, the strings “ABC,” “abc,” and “Abc” are treated equally in the search limit evaluation.
- For all operators other than the “contains,” “does not contain,” and “begins with” operators, if the search limit expression value(s) and the search field value(s) in the source document can be converted to integers, then numeric comparisons are done in the search limit evaluation. For example, the operator is = (“equals”), the expression value is 123, and the value in a source document search field is 0123. The values are converted to the integer 123 for the search limit evaluation, and “123 = 123” comparison returns a result of TRUE. Therefore, the expression evaluation is TRUE.
-
When the search limit expression and/or the source document contains multiple values, then all combinations of values from the search limit expression and source document search fields are compared. If any one of the comparison results is TRUE, then the expression evaluation is TRUE even if the comparison results are not all TRUE; the exceptions are the operators “!=” and “does not contain.” For these two operators, if any one of the comparison results is FALSE, then the expression evaluation is FALSE even if the comparison results are not all FALSE.
-
In this example of multiple value comparisons for the expression and source document search fields with “positive” operators (=, <, <=, >, >=, contains, begins with), the search limit expression is "PUBDATE = 2006, 2007." This expression means that documents with a publication date equal to 2006 or 2007 will appear in the search results list.
In a source document, the PUBDATE search field is as follows:
Field Values PUBDATE
2007, 2008
Each value in the source document’s PUBDATE search field is compared independently to each search limit value. The comparison results are as follows.
Comparison Result Is 2007 = 2006?
FALSE
Is 2007 = 2007?
TRUE
Is 2008 = 2006?
FALSE
Is 2008 = 2007?
FALSE
Since at least one comparison result is TRUE, the search limit expression evaluation is TRUE for the source document. The source document will display in the search results when the search limit is applied.
-
In this example of a search limit evaluation with the negative operators “!=” and “does not contain”, the search limit expression is ""PUBDATE != "2006", "2007"." This expression means that documents with a publication date that is not equal to 2006 or 2007 will appear in the search results list.
In a source document, the PUBDATE search field contains the following values.
Field Values PUBDATE
2007, 2008
Each value in the source document’s PUBDATE search field is compared independently to each search limit value. The comparison results are as follows.
Comparison Result Is 2007 not equal to 2006?
TRUE
Is 2007 not equal to 2007?
FALSE
Is 2008 not equal to 2006?
TRUE
Is 2008 not equal to 2007?
TRUE
Since one comparison result is FALSE, the search limit expression evaluation is FALSE for the source document. The source document will be excluded from the search results where the search limit is applied.
-
-
If a search limit expression contains both parent and child type search fields, the expression is compared independently to each combination of parent and child search field values from the source document. If any comparison result is TRUE, then the expression evaluation is TRUE even if the comparison results are not all TRUE.
For example, the search limit expression is ( ("LIBRARY !="main"“) AND ("PUBDATE" = "2008")). This expression means that documents that have any child entry with a LIBRARY search field value that is not Main and have a publication date equal to 2008 will display in the search results list.
In MARC type data, the LIBRARY is a child field from the item record, and PUBDATE is a parent field from the bibliographic record. A source document has the LIBRARY and PUBDATE search fields with the following values.
Field Value PUBDATE
(In the bibliographic record)
2008
LIBRARY
(In the first item record)
Main
LIBRARY
(In the second item record)
North
The search limit expression is compared independently to each combination of publication date and library value in the source document. The comparison results are as follows.
Comparison Result Is “2008 equal to 2008” AND “main does not equal main”?
FALSE
Is "2008 equal to 2008” AND “north does not equal main"?
TRUE
Since at least one comparison result is TRUE, the search limit expression evaluation is TRUE for the source document. The document will display in the search results where the search limit is applied.
- If the search limit expression has at least one search field that is not valid for the index, the evaluation of the expression is determined by the Evaluation Type. For more information on Evaluation Type and how that setting functions, see Fields: Add/Edit Search Limit.
-
If the search limit expression has at least one search field that is valid but not present in the source document, the expression evaluation is always FALSE. If you want to include these items in your results, you should create a combined OR expression with the "is empty" operand.
For example, suppose the search limit expression is ( ( "PUBDATE = 2008) AND (NOTE does not contain "local") ), which means Publication date equals 2008 AND Note does not contain the string “local.” Although it can be argued that a bibliographic record that does not have a NOTE search field will satisfy the “NOTE does not contain ‘local’” part of the expression, the absence of a specified, a valid search field in the source document will always return an evaluation of FALSE for the entire search limit expression. However, if you created the expressions ( (PUBDATE = 2008) AND ( (NOTE does not contain "local") OR (NOTE is empty) ) ), the bibliographic record without the NOTE search field would be included in the results.
Related topics
Understanding and creating operands for search limits