Java Doc for PrecedenceQueryParser.java in  » Net » lucene-connector » org » apache » lucene » queryParser » precedence » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » lucene connector » org.apache.lucene.queryParser.precedence 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.lucene.queryParser.precedence.PrecedenceQueryParser

PrecedenceQueryParser
public class PrecedenceQueryParser implements PrecedenceQueryParserConstants(Code)
Experimental query parser variant designed to handle operator precedence in a more sensible fashion than QueryParser. There are still some open issues with this parser. The following tests are currently failing in TestPrecedenceQueryParser and are disabled to make this test pass:
  • testSimple
  • testWildcard
  • testPrecedence
This class is generated by JavaCC. The only method that clients should need to call is PrecedenceQueryParser.parse(String) . The syntax for query strings is as follows: A Query is a series of clauses. A clause may be prefixed by:
  • a plus (+) or a minus (-) sign, indicating that the clause is required or prohibited respectively; or
  • a term followed by a colon, indicating the field to be searched. This enables one to construct queries which search multiple fields.
A clause may be either:
  • a term, indicating all the documents that contain this term; or
  • a nested query, enclosed in parentheses. Note that this may be used with a +/- prefix to require any of a set of terms.
Thus, in BNF, the query grammar is:
 Query  ::= ( Clause )*
 Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
 

Examples of appropriately formatted queries can be found in the query syntax documentation.


author:
   Brian Goetz
author:
   Peter Halacsy
author:
   Tatu Saloranta

Inner Class :final static class Operator extends Parameter
Inner Class :final static class JJCalls

Field Summary
final public static  OperatorAND_OPERATOR
    
final public static  OperatorOR_OPERATOR
    
 Analyzeranalyzer
    
 Stringfield
    
 floatfuzzyMinSim
    
 intfuzzyPrefixLength
    
 Localelocale
    
public  booleanlookingAhead
    
 booleanlowercaseExpandedTerms
    
 intphraseSlop
    
public  PrecedenceQueryParserTokenManagertoken_source
    
public  Tokentokenjj_nt
    

Constructor Summary
public  PrecedenceQueryParser(String f, Analyzer a)
     Constructs a query parser.
public  PrecedenceQueryParser(CharStream stream)
    
public  PrecedenceQueryParser(PrecedenceQueryParserTokenManager tm)
    

Method Summary
final public  QueryClause(String field)
    
final public  intConjunction()
    
final public  intModifier()
    
final public  QueryQuery(String field)
    
public  voidReInit(CharStream stream)
    
public  voidReInit(PrecedenceQueryParserTokenManager tm)
    
final public  QueryTerm(String field)
    
protected  voidaddClause(Vector clauses, int conj, int modifier, Query q)
    
final public  QueryandExpression(String field)
    
final public  voiddisable_tracing()
    
final public  voidenable_tracing()
    
public static  Stringescape(String s)
     Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding \.
public  ParseExceptiongenerateParseException()
    
public  AnalyzergetAnalyzer()
    
protected  QuerygetBooleanQuery(Vector clauses)
     Factory method for generating query, given a set of clauses. By default creates a boolean query composed of clauses passed in. Can be overridden by extending classes, to modify query being returned.
Parameters:
  clauses - Vector that contains BooleanClause instancesto join.
protected  QuerygetBooleanQuery(Vector clauses, boolean disableCoord)
     Factory method for generating query, given a set of clauses. By default creates a boolean query composed of clauses passed in. Can be overridden by extending classes, to modify query being returned.
Parameters:
  clauses - Vector that contains BooleanClause instancesto join.
Parameters:
  disableCoord - true if coord scoring should be disabled.
public  OperatorgetDefaultOperator()
     Gets implicit operator setting, which will be either AND_OPERATOR or OR_OPERATOR.
public  StringgetField()
    
protected  QuerygetFieldQuery(String field, String queryText)
    
protected  QuerygetFieldQuery(String field, String queryText, int slop)
     Base implementation delegates to PrecedenceQueryParser.getFieldQuery(String,String) .
public  floatgetFuzzyMinSim()
     Get the minimal similarity for fuzzy queries.
public  intgetFuzzyPrefixLength()
     Get the prefix length for fuzzy queries.
protected  QuerygetFuzzyQuery(String field, String termStr, float minSimilarity)
     Factory method for generating a query (similar to PrecedenceQueryParser.getWildcardQuery ).
public  LocalegetLocale()
     Returns current locale, allowing access by subclasses.
public  booleangetLowercaseExpandedTerms()
    
final public  TokengetNextToken()
    
public  intgetPhraseSlop()
     Gets the default slop for phrases.
protected  QuerygetPrefixQuery(String field, String termStr)
     Factory method for generating a query (similar to PrecedenceQueryParser.getWildcardQuery ).
protected  QuerygetRangeQuery(String field, String part1, String part2, boolean inclusive)
    
final public  TokengetToken(int index)
    
protected  QuerygetWildcardQuery(String field, String termStr)
     Factory method for generating a query.
public static  voidmain(String[] args)
     Command line tool to test QueryParser, using org.apache.lucene.analysis.SimpleAnalyzer .
public  Queryparse(String expression)
     Parses a query string, returning a org.apache.lucene.search.Query .
public  voidsetDefaultOperator(Operator op)
     Sets the boolean operator of the QueryParser.
public  voidsetFuzzyMinSim(float fuzzyMinSim)
     Set the minimum similarity for fuzzy queries.
public  voidsetFuzzyPrefixLength(int fuzzyPrefixLength)
     Set the prefix length for fuzzy queries.
public  voidsetLocale(Locale locale)
     Set locale used by date range parsing.
public  voidsetLowercaseExpandedTerms(boolean lowercaseExpandedTerms)
     Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not.
public  voidsetPhraseSlop(int phraseSlop)
     Sets the default slop for phrases.

Field Detail
AND_OPERATOR
final public static Operator AND_OPERATOR(Code)



OR_OPERATOR
final public static Operator OR_OPERATOR(Code)



analyzer
Analyzer analyzer(Code)



field
String field(Code)



fuzzyMinSim
float fuzzyMinSim(Code)



fuzzyPrefixLength
int fuzzyPrefixLength(Code)



locale
Locale locale(Code)



lookingAhead
public boolean lookingAhead(Code)



lowercaseExpandedTerms
boolean lowercaseExpandedTerms(Code)



phraseSlop
int phraseSlop(Code)



token_source
public PrecedenceQueryParserTokenManager token_source(Code)



tokenjj_nt
public Token tokenjj_nt(Code)




Constructor Detail
PrecedenceQueryParser
public PrecedenceQueryParser(String f, Analyzer a)(Code)
Constructs a query parser.
Parameters:
  f - the default field for query terms.
Parameters:
  a - used to find terms in the query text.



PrecedenceQueryParser
public PrecedenceQueryParser(CharStream stream)(Code)



PrecedenceQueryParser
public PrecedenceQueryParser(PrecedenceQueryParserTokenManager tm)(Code)




Method Detail
Clause
final public Query Clause(String field) throws ParseException(Code)



Conjunction
final public int Conjunction() throws ParseException(Code)



Modifier
final public int Modifier() throws ParseException(Code)



Query
final public Query Query(String field) throws ParseException(Code)



ReInit
public void ReInit(CharStream stream)(Code)



ReInit
public void ReInit(PrecedenceQueryParserTokenManager tm)(Code)



Term
final public Query Term(String field) throws ParseException(Code)



addClause
protected void addClause(Vector clauses, int conj, int modifier, Query q)(Code)



andExpression
final public Query andExpression(String field) throws ParseException(Code)



disable_tracing
final public void disable_tracing()(Code)



enable_tracing
final public void enable_tracing()(Code)



escape
public static String escape(String s)(Code)
Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding \.



generateParseException
public ParseException generateParseException()(Code)



getAnalyzer
public Analyzer getAnalyzer()(Code)
Returns the analyzer.



getBooleanQuery
protected Query getBooleanQuery(Vector clauses) throws ParseException(Code)
Factory method for generating query, given a set of clauses. By default creates a boolean query composed of clauses passed in. Can be overridden by extending classes, to modify query being returned.
Parameters:
  clauses - Vector that contains BooleanClause instancesto join. Resulting Query object.
exception:
  ParseException - throw in overridden method to disallow



getBooleanQuery
protected Query getBooleanQuery(Vector clauses, boolean disableCoord) throws ParseException(Code)
Factory method for generating query, given a set of clauses. By default creates a boolean query composed of clauses passed in. Can be overridden by extending classes, to modify query being returned.
Parameters:
  clauses - Vector that contains BooleanClause instancesto join.
Parameters:
  disableCoord - true if coord scoring should be disabled. Resulting Query object.
exception:
  ParseException - throw in overridden method to disallow



getDefaultOperator
public Operator getDefaultOperator()(Code)
Gets implicit operator setting, which will be either AND_OPERATOR or OR_OPERATOR.



getField
public String getField()(Code)
Returns the field.



getFieldQuery
protected Query getFieldQuery(String field, String queryText) throws ParseException(Code)

exception:
  ParseException - throw in overridden method to disallow



getFieldQuery
protected Query getFieldQuery(String field, String queryText, int slop) throws ParseException(Code)
Base implementation delegates to PrecedenceQueryParser.getFieldQuery(String,String) . This method may be overridden, for example, to return a SpanNearQuery instead of a PhraseQuery.
exception:
  ParseException - throw in overridden method to disallow



getFuzzyMinSim
public float getFuzzyMinSim()(Code)
Get the minimal similarity for fuzzy queries.



getFuzzyPrefixLength
public int getFuzzyPrefixLength()(Code)
Get the prefix length for fuzzy queries. Returns the fuzzyPrefixLength.



getFuzzyQuery
protected Query getFuzzyQuery(String field, String termStr, float minSimilarity) throws ParseException(Code)
Factory method for generating a query (similar to PrecedenceQueryParser.getWildcardQuery ). Called when parser parses an input term token that has the fuzzy suffix (~) appended.
Parameters:
  field - Name of the field query will use.
Parameters:
  termStr - Term token to use for building term for the query Resulting Query built for the term
exception:
  ParseException - throw in overridden method to disallow



getLocale
public Locale getLocale()(Code)
Returns current locale, allowing access by subclasses.



getLowercaseExpandedTerms
public boolean getLowercaseExpandedTerms()(Code)

See Also:   PrecedenceQueryParser.setLowercaseExpandedTerms(boolean)



getNextToken
final public Token getNextToken()(Code)



getPhraseSlop
public int getPhraseSlop()(Code)
Gets the default slop for phrases.



getPrefixQuery
protected Query getPrefixQuery(String field, String termStr) throws ParseException(Code)
Factory method for generating a query (similar to PrecedenceQueryParser.getWildcardQuery ). Called when parser parses an input term token that uses prefix notation; that is, contains a single '*' wildcard character as its last character. Since this is a special case of generic wildcard term, and such a query can be optimized easily, this usually results in a different query object.

Depending on settings, a prefix term may be lower-cased automatically. It will not go through the default Analyzer, however, since normal Analyzers are unlikely to work properly with wildcard templates.

Can be overridden by extending classes, to provide custom handling for wild card queries, which may be necessary due to missing analyzer calls.
Parameters:
  field - Name of the field query will use.
Parameters:
  termStr - Term token to use for building term for the query(without trailing '*' character!) Resulting Query built for the term
exception:
  ParseException - throw in overridden method to disallow




getRangeQuery
protected Query getRangeQuery(String field, String part1, String part2, boolean inclusive) throws ParseException(Code)

exception:
  ParseException - throw in overridden method to disallow



getToken
final public Token getToken(int index)(Code)



getWildcardQuery
protected Query getWildcardQuery(String field, String termStr) throws ParseException(Code)
Factory method for generating a query. Called when parser parses an input term token that contains one or more wildcard characters (? and *), but is not a prefix term token (one that has just a single * character at the end)

Depending on settings, prefix term may be lower-cased automatically. It will not go through the default Analyzer, however, since normal Analyzers are unlikely to work properly with wildcard templates.

Can be overridden by extending classes, to provide custom handling for wildcard queries, which may be necessary due to missing analyzer calls.
Parameters:
  field - Name of the field query will use.
Parameters:
  termStr - Term token that contains one or more wild cardcharacters (? or *), but is not simple prefix term Resulting Query built for the term
exception:
  ParseException - throw in overridden method to disallow




main
public static void main(String[] args) throws Exception(Code)
Command line tool to test QueryParser, using org.apache.lucene.analysis.SimpleAnalyzer . Usage:
java org.apache.lucene.queryParser.QueryParser <input>



parse
public Query parse(String expression) throws ParseException(Code)
Parses a query string, returning a org.apache.lucene.search.Query .
Parameters:
  expression - the query string to be parsed.
throws:
  ParseException - if the parsing fails



setDefaultOperator
public void setDefaultOperator(Operator op)(Code)
Sets the boolean operator of the QueryParser. In default mode (OR_OPERATOR) terms without any modifiers are considered optional: for example capital of Hungary is equal to capital OR of OR Hungary.
In AND_OPERATOR mode terms are considered to be in conjuction: the above mentioned query is parsed as capital AND of AND Hungary



setFuzzyMinSim
public void setFuzzyMinSim(float fuzzyMinSim)(Code)
Set the minimum similarity for fuzzy queries. Default is 0.5f.



setFuzzyPrefixLength
public void setFuzzyPrefixLength(int fuzzyPrefixLength)(Code)
Set the prefix length for fuzzy queries. Default is 0.
Parameters:
  fuzzyPrefixLength - The fuzzyPrefixLength to set.



setLocale
public void setLocale(Locale locale)(Code)
Set locale used by date range parsing.



setLowercaseExpandedTerms
public void setLowercaseExpandedTerms(boolean lowercaseExpandedTerms)(Code)
Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not. Default is true.



setPhraseSlop
public void setPhraseSlop(int phraseSlop)(Code)
Sets the default slop for phrases. If zero, then exact phrase matches are required. Default value is zero.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.