mirror of https://github.com/apache/lucene.git
Added a flag for wildcard case-insensitivity.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150863 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1f66680c18
commit
1843c58c5c
|
@ -1,12 +1,13 @@
|
|||
//
|
||||
// JavaScript Lucene Query Validator
|
||||
// Author: Kelvin Tan (kelvin@relevanz.com)
|
||||
// Date: 10/04/2002
|
||||
// Date: 03/12/2002
|
||||
// JavaScript Lucene Query Validator
|
||||
// Version: $Id$
|
||||
|
||||
// validates a lucene query.
|
||||
// @param Form field that contains the query
|
||||
function doCheckLuceneQuery(queryField)
|
||||
{
|
||||
var wildcardCaseInsensitive = true;
|
||||
var query = queryField.value;
|
||||
if(query != null && query.length > 0)
|
||||
{
|
||||
|
@ -20,7 +21,7 @@ function doCheckLuceneQuery(queryField)
|
|||
}
|
||||
|
||||
// check parentheses are used properly
|
||||
matches = query.match(/^([^\n()]*|(\(([a-zA-Z0-9_+\-:()\" ]|\*)+\)))*$/);
|
||||
matches = query.match(/^([^\n()]*|(\(([a-zA-Z0-9_+\-:()\" ]|\*)+\)))*$/);
|
||||
if(matches == null || matches.length == 0)
|
||||
{
|
||||
alert("Invalid search query! Parentheses must contain at least one alphabet or number. Please try again.")
|
||||
|
@ -48,13 +49,21 @@ function doCheckLuceneQuery(queryField)
|
|||
}
|
||||
|
||||
// check ':' is used properly
|
||||
matches = query.match(/^(([^\n:]*|([a-zA-Z0-9_]|\*)+[:]([a-zA-Z0-9_()"]|\*)+))*$/);
|
||||
matches = query.match(/^(([^\n:]*|([a-zA-Z0-9_]|\*)+[:]([a-zA-Z0-9_()"]|\*)+))*$/);
|
||||
if(matches == null || matches.length == 0)
|
||||
{
|
||||
alert("Invalid search query! Field declarations (:) must be preceded by at least one alphabet or number and followed by at least one alphabet or number. Please try again.")
|
||||
return false;
|
||||
}
|
||||
|
||||
if(wildcardCaseInsensitive)
|
||||
{
|
||||
if(query.indexOf("*") != -1)
|
||||
{
|
||||
queryField.value = query.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue