queryparser.html
来自「 Lucene是apache软件基金会[4] jakarta项目组的一个子项目」· HTML 代码 · 共 1,243 行 · 第 1/5 页
HTML
1,243 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.4.2_04) on Wed Feb 14 11:49:17 EST 2007 -->
<TITLE>
QueryParser (Lucene 2.1.0 API)
</TITLE>
<META NAME="keywords" CONTENT="org.apache.lucene.queryParser.QueryParser class">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="QueryParser (Lucene 2.1.0 API)";
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/QueryParser.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../org/apache/lucene/queryParser/MultiFieldQueryParser.html" title="class in org.apache.lucene.queryParser"><B>PREV CLASS</B></A>
<A HREF="../../../../org/apache/lucene/queryParser/QueryParser.Operator.html" title="class in org.apache.lucene.queryParser"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html" target="_top"><B>FRAMES</B></A>
<A HREF="QueryParser.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: <A HREF="#nested_class_summary">NESTED</A> | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.apache.lucene.queryParser</FONT>
<BR>
Class QueryParser</H2>
<PRE>
<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</A>
<IMG SRC="../../../../resources/inherit.gif" ALT="extended by"><B>org.apache.lucene.queryParser.QueryParser</B>
</PRE>
<DL>
<DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../../org/apache/lucene/queryParser/QueryParserConstants.html" title="interface in org.apache.lucene.queryParser">QueryParserConstants</A></DD>
</DL>
<DL>
<DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../../org/apache/lucene/queryParser/analyzing/AnalyzingQueryParser.html" title="class in org.apache.lucene.queryParser.analyzing">AnalyzingQueryParser</A>, <A HREF="../../../../org/apache/lucene/queryParser/MultiFieldQueryParser.html" title="class in org.apache.lucene.queryParser">MultiFieldQueryParser</A></DD>
</DL>
<HR>
<DL>
<DT>public class <B>QueryParser</B><DT>extends <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A><DT>implements <A HREF="../../../../org/apache/lucene/queryParser/QueryParserConstants.html" title="interface in org.apache.lucene.queryParser">QueryParserConstants</A></DL>
<P>
This class is generated by JavaCC. The most important method is <A HREF="../../../../org/apache/lucene/queryParser/QueryParser.html#parse(java.lang.String)"><CODE>parse(String)</CODE></A>. The syntax for query strings is as follows: A Query is a series of clauses. A clause may be prefixed by: <ul> <li> a plus (<code>+</code>) or a minus (<code>-</code>) sign, indicating that the clause is required or prohibited respectively; or <li> a term followed by a colon, indicating the field to be searched. This enables one to construct queries which search multiple fields. </ul> A clause may be either: <ul> <li> a term, indicating all the documents that contain this term; or <li> a nested query, enclosed in parentheses. Note that this may be used with a <code>+</code>/<code>-</code> prefix to require any of a set of terms. </ul> Thus, in BNF, the query grammar is: <pre> Query ::= ( Clause )* Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" ) </pre> <p> Examples of appropriately formatted queries can be found in the <a href="http://lucene.apache.org/java/docs/queryparsersyntax.html">query syntax documentation</a>. </p> <p> In <A HREF="../../../../org/apache/lucene/search/RangeQuery.html" title="class in org.apache.lucene.search"><CODE>RangeQuery</CODE></A>s, QueryParser tries to detect date values, e.g. <tt>date:[6/1/2005 TO 6/4/2005]</tt> produces a range query that searches for "date" fields between 2005-06-01 and 2005-06-04. Note that the format of the accepted input depends on <A HREF="../../../../org/apache/lucene/queryParser/QueryParser.html#setLocale(java.util.Locale)"><CODE>the locale</CODE></A>. By default a date is converted into a search term using the deprecated <A HREF="../../../../org/apache/lucene/document/DateField.html" title="class in org.apache.lucene.document"><CODE>DateField</CODE></A> for compatibility reasons. To use the new <A HREF="../../../../org/apache/lucene/document/DateTools.html" title="class in org.apache.lucene.document"><CODE>DateTools</CODE></A> to convert dates, a <CODE>DateTools.Resolution</CODE> has to be set. </p> <p> The date resolution that shall be used for RangeQueries can be set using <A HREF="../../../../org/apache/lucene/queryParser/QueryParser.html#setDateResolution(org.apache.lucene.document.DateTools.Resolution)"><CODE>setDateResolution(DateTools.Resolution)</CODE></A> or <A HREF="../../../../org/apache/lucene/queryParser/QueryParser.html#setDateResolution(java.lang.String, org.apache.lucene.document.DateTools.Resolution)"><CODE>setDateResolution(String, DateTools.Resolution)</CODE></A>. The former sets the default date resolution for all fields, whereas the latter can be used to set field specific date resolutions. Field specific date resolutions take, if set, precedence over the default date resolution. </p> <p> If you use neither <A HREF="../../../../org/apache/lucene/document/DateField.html" title="class in org.apache.lucene.document"><CODE>DateField</CODE></A> nor <A HREF="../../../../org/apache/lucene/document/DateTools.html" title="class in org.apache.lucene.document"><CODE>DateTools</CODE></A> in your index, you can create your own query parser that inherits QueryParser and overwrites <A HREF="../../../../org/apache/lucene/queryParser/QueryParser.html#getRangeQuery(java.lang.String, java.lang.String, java.lang.String, boolean)"><CODE>getRangeQuery(String, String, String, boolean)</CODE></A> to use a different method for date conversion. </p> <p>Note that QueryParser is <em>not</em> thread-safe.</p>
<P>
<P>
<DL>
<DT><B>Author:</B></DT> <DD>Brian Goetz, Peter Halacsy, Tatu Saloranta</DD></DL>
<HR>
<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->
<A NAME="nested_class_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Nested Class Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/queryParser/QueryParser.Operator.html" title="class in org.apache.lucene.queryParser">QueryParser.Operator</A></B></CODE>
<BR>
The default operator for parsing queries.</TD>
</TR>
</TABLE>
<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Field Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static <A HREF="../../../../org/apache/lucene/queryParser/QueryParser.Operator.html" title="class in org.apache.lucene.queryParser">QueryParser.Operator</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/queryParser/QueryParser.html#AND_OPERATOR">AND_OPERATOR</A></B></CODE>
<BR>
Alternative form of QueryParser.Operator.AND</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../../org/apache/lucene/queryParser/Token.html" title="class in org.apache.lucene.queryParser">Token</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/queryParser/QueryParser.html#jj_nt">jj_nt</A></B></CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/queryParser/QueryParser.html#lookingAhead">lookingAhead</A></B></CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static <A HREF="../../../../org/apache/lucene/queryParser/QueryParser.Operator.html" title="class in org.apache.lucene.queryParser">QueryParser.Operator</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/queryParser/QueryParser.html#OR_OPERATOR">OR_OPERATOR</A></B></CODE>
<BR>
Alternative form of QueryParser.Operator.OR</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../../org/apache/lucene/queryParser/Token.html" title="class in org.apache.lucene.queryParser">Token</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/queryParser/QueryParser.html#token">token</A></B></CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../../org/apache/lucene/queryParser/QueryParserTokenManager.html" title="class in org.apache.lucene.queryParser">QueryParserTokenManager</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/queryParser/QueryParser.html#token_source">token_source</A></B></CODE>
<BR>
</TD>
</TR>
</TABLE>
<A NAME="fields_inherited_from_class_org.apache.lucene.queryParser.QueryParserConstants"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?