SOLR-2452: Merged with trunk up to r1143468

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/solr2452@1143567 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Steven Rowe 2011-07-06 21:16:33 +00:00
commit 9abc6a2912
754 changed files with 48873 additions and 8098 deletions

View File

@ -38,10 +38,13 @@
<classpathentry kind="src" path="modules/analysis/stempel/src/java"/> <classpathentry kind="src" path="modules/analysis/stempel/src/java"/>
<classpathentry kind="src" path="modules/analysis/stempel/src/resources"/> <classpathentry kind="src" path="modules/analysis/stempel/src/resources"/>
<classpathentry kind="src" path="modules/analysis/stempel/src/test"/> <classpathentry kind="src" path="modules/analysis/stempel/src/test"/>
<classpathentry kind="src" path="modules/analysis/morfologik/src/java"/>
<classpathentry kind="src" path="modules/analysis/morfologik/src/test"/>
<classpathentry kind="src" path="modules/benchmark/src/java"/> <classpathentry kind="src" path="modules/benchmark/src/java"/>
<classpathentry kind="src" path="modules/benchmark/src/test"/> <classpathentry kind="src" path="modules/benchmark/src/test"/>
<classpathentry kind="src" path="modules/common/src/java"/> <classpathentry kind="src" path="modules/facet/src/java"/>
<classpathentry kind="src" path="modules/common/src/test"/> <classpathentry kind="src" path="modules/facet/src/examples"/>
<classpathentry kind="src" path="modules/facet/src/test"/>
<classpathentry kind="src" path="modules/grouping/src/java"/> <classpathentry kind="src" path="modules/grouping/src/java"/>
<classpathentry kind="src" path="modules/grouping/src/test"/> <classpathentry kind="src" path="modules/grouping/src/test"/>
<classpathentry kind="src" path="modules/queries/src/java"/> <classpathentry kind="src" path="modules/queries/src/java"/>
@ -80,6 +83,9 @@
<classpathentry kind="lib" path="lucene/contrib/queries/lib/jakarta-regexp-1.4.jar"/> <classpathentry kind="lib" path="lucene/contrib/queries/lib/jakarta-regexp-1.4.jar"/>
<classpathentry kind="lib" path="modules/analysis/icu/lib/icu4j-4_8.jar"/> <classpathentry kind="lib" path="modules/analysis/icu/lib/icu4j-4_8.jar"/>
<classpathentry kind="lib" path="modules/analysis/phonetic/lib/commons-codec-1.4.jar"/> <classpathentry kind="lib" path="modules/analysis/phonetic/lib/commons-codec-1.4.jar"/>
<classpathentry kind="lib" path="modules/analysis/morfologik/lib/morfologik-fsa-1.5.2.jar"/>
<classpathentry kind="lib" path="modules/analysis/morfologik/lib/morfologik-polish-1.5.2.jar"/>
<classpathentry kind="lib" path="modules/analysis/morfologik/lib/morfologik-stemming-1.5.2.jar"/>
<classpathentry kind="lib" path="modules/benchmark/lib/commons-beanutils-1.7.0.jar"/> <classpathentry kind="lib" path="modules/benchmark/lib/commons-beanutils-1.7.0.jar"/>
<classpathentry kind="lib" path="modules/benchmark/lib/commons-collections-3.1.jar"/> <classpathentry kind="lib" path="modules/benchmark/lib/commons-collections-3.1.jar"/>
<classpathentry kind="lib" path="modules/benchmark/lib/commons-compress-1.1.jar"/> <classpathentry kind="lib" path="modules/benchmark/lib/commons-compress-1.1.jar"/>

View File

@ -158,7 +158,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.source" value="1.5"/> <setting id="org.eclipse.jdt.core.compiler.source" value="1.6"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
@ -167,7 +167,7 @@
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.5"/> <setting id="org.eclipse.jdt.core.compiler.compliance" value="1.6"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/> <setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
@ -203,7 +203,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.5"/> <setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.6"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/>

View File

@ -15,11 +15,14 @@
<buildFile url="file://$PROJECT_DIR$/lucene/contrib/xml-query-parser/build.xml" /> <buildFile url="file://$PROJECT_DIR$/lucene/contrib/xml-query-parser/build.xml" />
<buildFile url="file://$PROJECT_DIR$/modules/analysis/common/build.xml" /> <buildFile url="file://$PROJECT_DIR$/modules/analysis/common/build.xml" />
<buildFile url="file://$PROJECT_DIR$/modules/analysis/icu/build.xml" /> <buildFile url="file://$PROJECT_DIR$/modules/analysis/icu/build.xml" />
<buildFile url="file://$PROJECT_DIR$/modules/analysis/morfologik/build.xml" />
<buildFile url="file://$PROJECT_DIR$/modules/analysis/phonetic/build.xml" /> <buildFile url="file://$PROJECT_DIR$/modules/analysis/phonetic/build.xml" />
<buildFile url="file://$PROJECT_DIR$/modules/analysis/smartcn/build.xml" /> <buildFile url="file://$PROJECT_DIR$/modules/analysis/smartcn/build.xml" />
<buildFile url="file://$PROJECT_DIR$/modules/analysis/stempel/build.xml" /> <buildFile url="file://$PROJECT_DIR$/modules/analysis/stempel/build.xml" />
<buildFile url="file://$PROJECT_DIR$/modules/benchmark/build.xml" /> <buildFile url="file://$PROJECT_DIR$/modules/benchmark/build.xml" />
<buildFile url="file://$PROJECT_DIR$/modules/facet/build.xml" />
<buildFile url="file://$PROJECT_DIR$/modules/grouping/build.xml" /> <buildFile url="file://$PROJECT_DIR$/modules/grouping/build.xml" />
<buildFile url="file://$PROJECT_DIR$/modules/join/build.xml" />
<buildFile url="file://$PROJECT_DIR$/modules/suggest/build.xml" /> <buildFile url="file://$PROJECT_DIR$/modules/suggest/build.xml" />
<buildFile url="file://$PROJECT_DIR$/solr/build.xml" /> <buildFile url="file://$PROJECT_DIR$/solr/build.xml" />
<buildFile url="file://$PROJECT_DIR$/solr/contrib/analysis-extras/build.xml" /> <buildFile url="file://$PROJECT_DIR$/solr/contrib/analysis-extras/build.xml" />

View File

@ -16,12 +16,14 @@
<module filepath="$PROJECT_DIR$/lucene/contrib/xml-query-parser/xml-query-parser.iml" /> <module filepath="$PROJECT_DIR$/lucene/contrib/xml-query-parser/xml-query-parser.iml" />
<module filepath="$PROJECT_DIR$/modules/analysis/common/analysis-common.iml" /> <module filepath="$PROJECT_DIR$/modules/analysis/common/analysis-common.iml" />
<module filepath="$PROJECT_DIR$/modules/analysis/icu/icu.iml" /> <module filepath="$PROJECT_DIR$/modules/analysis/icu/icu.iml" />
<module filepath="$PROJECT_DIR$/modules/analysis/morfologik/morfologik.iml" />
<module filepath="$PROJECT_DIR$/modules/analysis/phonetic/phonetic.iml" /> <module filepath="$PROJECT_DIR$/modules/analysis/phonetic/phonetic.iml" />
<module filepath="$PROJECT_DIR$/modules/analysis/smartcn/smartcn.iml" /> <module filepath="$PROJECT_DIR$/modules/analysis/smartcn/smartcn.iml" />
<module filepath="$PROJECT_DIR$/modules/analysis/stempel/stempel.iml" /> <module filepath="$PROJECT_DIR$/modules/analysis/stempel/stempel.iml" />
<module filepath="$PROJECT_DIR$/modules/benchmark/benchmark.iml" /> <module filepath="$PROJECT_DIR$/modules/benchmark/benchmark.iml" />
<module filepath="$PROJECT_DIR$/modules/common/common.iml" /> <module filepath="$PROJECT_DIR$/modules/facet/facet.iml" />
<module filepath="$PROJECT_DIR$/modules/grouping/grouping.iml" /> <module filepath="$PROJECT_DIR$/modules/grouping/grouping.iml" />
<module filepath="$PROJECT_DIR$/modules/join/join.iml" />
<module filepath="$PROJECT_DIR$/modules/queries/queries.iml" /> <module filepath="$PROJECT_DIR$/modules/queries/queries.iml" />
<module filepath="$PROJECT_DIR$/modules/suggest/suggest.iml" /> <module filepath="$PROJECT_DIR$/modules/suggest/suggest.iml" />
<module filepath="$PROJECT_DIR$/solr/solr.iml" /> <module filepath="$PROJECT_DIR$/solr/solr.iml" />

View File

@ -22,13 +22,6 @@
<option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=4.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" /> <option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=4.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" />
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option> <option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
</configuration> </configuration>
<configuration default="false" name="common module" type="JUnit" factoryName="JUnit">
<module name="common" />
<option name="TEST_OBJECT" value="package" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/modules/common/build" />
<option name="VM_PARAMETERS" value="-ea -DtempDir=temp" />
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
</configuration>
<configuration default="false" name="common analysis module" type="JUnit" factoryName="JUnit"> <configuration default="false" name="common analysis module" type="JUnit" factoryName="JUnit">
<module name="analysis-common" /> <module name="analysis-common" />
<option name="TEST_OBJECT" value="package" /> <option name="TEST_OBJECT" value="package" />
@ -190,34 +183,33 @@
<option name="VM_PARAMETERS" value="-ea -DtempDir=temp" /> <option name="VM_PARAMETERS" value="-ea -DtempDir=temp" />
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option> <option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
</configuration> </configuration>
<list size="27"> <list size="26">
<item index="0" class="java.lang.String" itemvalue="JUnit.analysis-extras contrib" /> <item index="0" class="java.lang.String" itemvalue="JUnit.analysis-extras contrib" />
<item index="1" class="java.lang.String" itemvalue="JUnit.benchmark module" /> <item index="1" class="java.lang.String" itemvalue="JUnit.benchmark module" />
<item index="2" class="java.lang.String" itemvalue="JUnit.clustering contrib" /> <item index="2" class="java.lang.String" itemvalue="JUnit.clustering contrib" />
<item index="3" class="java.lang.String" itemvalue="JUnit.common module" /> <item index="3" class="java.lang.String" itemvalue="JUnit.common analysis module" />
<item index="4" class="java.lang.String" itemvalue="JUnit.common analysis module" /> <item index="4" class="java.lang.String" itemvalue="JUnit.dataimporthandler contrib" />
<item index="5" class="java.lang.String" itemvalue="JUnit.dataimporthandler contrib" /> <item index="5" class="java.lang.String" itemvalue="JUnit.dataimporthandler-extras contrib" />
<item index="6" class="java.lang.String" itemvalue="JUnit.dataimporthandler-extras contrib" /> <item index="6" class="java.lang.String" itemvalue="JUnit.extraction contrib" />
<item index="7" class="java.lang.String" itemvalue="JUnit.extraction contrib" /> <item index="7" class="java.lang.String" itemvalue="JUnit.grouping module" />
<item index="8" class="java.lang.String" itemvalue="JUnit.grouping module" /> <item index="8" class="java.lang.String" itemvalue="JUnit.highlighter contrib" />
<item index="9" class="java.lang.String" itemvalue="JUnit.highlighter contrib" /> <item index="9" class="java.lang.String" itemvalue="JUnit.icu analysis module" />
<item index="10" class="java.lang.String" itemvalue="JUnit.icu analysis module" /> <item index="10" class="java.lang.String" itemvalue="JUnit.instantiated contrib" />
<item index="11" class="java.lang.String" itemvalue="JUnit.instantiated contrib" /> <item index="11" class="java.lang.String" itemvalue="JUnit.lucene" />
<item index="12" class="java.lang.String" itemvalue="JUnit.lucene" /> <item index="12" class="java.lang.String" itemvalue="JUnit.memory contrib" />
<item index="13" class="java.lang.String" itemvalue="JUnit.memory contrib" /> <item index="13" class="java.lang.String" itemvalue="JUnit.misc contrib" />
<item index="14" class="java.lang.String" itemvalue="JUnit.misc contrib" /> <item index="14" class="java.lang.String" itemvalue="JUnit.phonetic analysis module" />
<item index="15" class="java.lang.String" itemvalue="JUnit.phonetic analysis module" /> <item index="15" class="java.lang.String" itemvalue="JUnit.queries contrib" />
<item index="16" class="java.lang.String" itemvalue="JUnit.queries contrib" /> <item index="16" class="java.lang.String" itemvalue="JUnit.queries module" />
<item index="17" class="java.lang.String" itemvalue="JUnit.queries module" /> <item index="17" class="java.lang.String" itemvalue="JUnit.queryparser contrib" />
<item index="18" class="java.lang.String" itemvalue="JUnit.queryparser contrib" /> <item index="18" class="java.lang.String" itemvalue="JUnit.smartcn analysis module" />
<item index="19" class="java.lang.String" itemvalue="JUnit.smartcn analysis module" /> <item index="19" class="java.lang.String" itemvalue="JUnit.solr" />
<item index="20" class="java.lang.String" itemvalue="JUnit.solr" /> <item index="20" class="java.lang.String" itemvalue="JUnit.spatial contrib" />
<item index="21" class="java.lang.String" itemvalue="JUnit.spatial contrib" /> <item index="21" class="java.lang.String" itemvalue="JUnit.stempel analysis module" />
<item index="22" class="java.lang.String" itemvalue="JUnit.stempel analysis module" /> <item index="22" class="java.lang.String" itemvalue="JUnit.suggest module" />
<item index="23" class="java.lang.String" itemvalue="JUnit.suggest module" /> <item index="23" class="java.lang.String" itemvalue="JUnit.uima contrib" />
<item index="24" class="java.lang.String" itemvalue="JUnit.uima contrib" /> <item index="24" class="java.lang.String" itemvalue="JUnit.wordnet contrib" />
<item index="25" class="java.lang.String" itemvalue="JUnit.wordnet contrib" /> <item index="25" class="java.lang.String" itemvalue="JUnit.xml-query-parser contrib" />
<item index="26" class="java.lang.String" itemvalue="JUnit.xml-query-parser contrib" />
</list> </list>
</component> </component>
</project> </project>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/../build/morfologik/classes/java" />
<output-test url="file://$MODULE_DIR$/../build/morfologik/classes/test" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/lib" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$MODULE_DIR$/lib" recursive="false" />
</library>
</orderEntry>
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
<orderEntry type="module" module-name="analysis-common" />
<orderEntry type="module" module-name="lucene" />
</component>
</module>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/classes/java" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/work" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
<orderEntry type="module" module-name="analysis-common" />
<orderEntry type="module" module-name="lucene" />
</component>
</module>

View File

@ -12,6 +12,7 @@
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="JUnit" level="project" /> <orderEntry type="library" scope="TEST" name="JUnit" level="project" />
<orderEntry type="module" module-name="grouping" />
<orderEntry type="module" module-name="lucene" /> <orderEntry type="module" module-name="lucene" />
</component> </component>
</module> </module>

View File

@ -13,6 +13,5 @@
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="JUnit" level="project" /> <orderEntry type="library" scope="TEST" name="JUnit" level="project" />
<orderEntry type="module" module-name="lucene" /> <orderEntry type="module" module-name="lucene" />
<orderEntry type="module" module-name="common" />
</component> </component>
</module> </module>

View File

@ -30,7 +30,6 @@
<orderEntry type="module" module-name="misc" /> <orderEntry type="module" module-name="misc" />
<orderEntry type="module" module-name="phonetic" /> <orderEntry type="module" module-name="phonetic" />
<orderEntry type="module" module-name="suggest" /> <orderEntry type="module" module-name="suggest" />
<orderEntry type="module" module-name="common" />
<orderEntry type="module" module-name="analysis-common" /> <orderEntry type="module" module-name="analysis-common" />
<orderEntry type="module" module-name="lucene" /> <orderEntry type="module" module-name="lucene" />
</component> </component>

View File

@ -21,7 +21,7 @@ A. How to use nightly Jenkins-built Lucene/Solr Maven artifacts
B. How to generate Lucene Maven artifacts B. How to generate Lucene Maven artifacts
1. Prerequisites: JDK 1.5+ and Ant 1.7.X 1. Prerequisites: JDK 1.6+ and Ant 1.7.X
2. Run the following command from the lucene/ directory: 2. Run the following command from the lucene/ directory:
@ -59,8 +59,7 @@ D. How to use Maven to build Lucene/Solr
The details, followed by some example Maven commands: The details, followed by some example Maven commands:
1. Prerequisites: JDK 1.5+ (for Lucene); JDK 1.6+ (for Solr); 1. Prerequisites: JDK 1.6+ and Maven 2.2.1 or 3.0.X
Maven 2.2.1 or 3.0.X
2. Make sure your sources are up to date. If you checked your sources out 2. Make sure your sources are up to date. If you checked your sources out
from the Apache Subversion repository, run "svn update" from the top from the Apache Subversion repository, run "svn update" from the top

View File

@ -0,0 +1,89 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-parent</artifactId>
<version>@version@</version>
<relativePath>../../../lucene/pom.xml</relativePath>
</parent>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-morfologik</artifactId>
<packaging>jar</packaging>
<name>Lucene Morfologik Polish Lemmatizer</name>
<description>
A dictionary-driven lemmatizer for Polish (includes morphosyntactic annotations)
</description>
<properties>
<module-directory>modules/analysis/morfologik</module-directory>
<build-directory>../build/morfologik</build-directory>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>lucene-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.carrot2</groupId>
<artifactId>morfologik-polish</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<directory>${build-directory}</directory>
<outputDirectory>${build-directory}/classes/java</outputDirectory>
<testOutputDirectory>${build-directory}/classes/test</testOutputDirectory>
<sourceDirectory>src/java</sourceDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
<testResources>
<testResource>
<directory>${project.build.testSourceDirectory}</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
</build>
</project>

View File

@ -33,6 +33,7 @@
<modules> <modules>
<module>common</module> <module>common</module>
<module>icu</module> <module>icu</module>
<module>morfologik</module>
<module>phonetic</module> <module>phonetic</module>
<module>smartcn</module> <module>smartcn</module>
<module>stempel</module> <module>stempel</module>

View File

@ -0,0 +1,98 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-parent</artifactId>
<version>@version@</version>
<relativePath>../../lucene/pom.xml</relativePath>
</parent>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-facet</artifactId>
<packaging>jar</packaging>
<name>Lucene Facets</name>
<description>
Package for Faceted Indexing and Search
</description>
<properties>
<module-directory>modules/facet</module-directory>
<build-directory>build</build-directory>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>lucene-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<directory>${build-directory}</directory>
<outputDirectory>${build-directory}/classes/java</outputDirectory>
<testOutputDirectory>${build-directory}/classes/test</testOutputDirectory>
<sourceDirectory>src/java</sourceDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
<testResources>
<testResource>
<directory>${project.build.testSourceDirectory}</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/examples</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,71 +1,76 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.apache.lucene</groupId> <groupId>org.apache.lucene</groupId>
<artifactId>lucene-parent</artifactId> <artifactId>lucene-parent</artifactId>
<version>@version@</version> <version>@version@</version>
<relativePath>../../lucene/pom.xml</relativePath> <relativePath>../../lucene/pom.xml</relativePath>
</parent> </parent>
<groupId>org.apache.lucene</groupId> <groupId>org.apache.lucene</groupId>
<artifactId>lucene-common-module</artifactId> <artifactId>lucene-join</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Lucene Common</name> <name>Lucene Join</name>
<description>Lucene Common Module</description> <description>Lucene Join Module</description>
<properties> <properties>
<module-directory>modules/common</module-directory> <module-directory>modules/join</module-directory>
<build-directory>build</build-directory> <build-directory>build</build-directory>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>lucene-core</artifactId> <artifactId>lucene-core</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>lucene-test-framework</artifactId> <artifactId>lucene-grouping</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> </dependency>
</dependency> <dependency>
<dependency> <groupId>${project.groupId}</groupId>
<groupId>junit</groupId> <artifactId>lucene-test-framework</artifactId>
<artifactId>junit</artifactId> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> <dependency>
<build> <groupId>junit</groupId>
<directory>${build-directory}</directory> <artifactId>junit</artifactId>
<outputDirectory>${build-directory}/classes/java</outputDirectory> <scope>test</scope>
<testOutputDirectory>${build-directory}/classes/test</testOutputDirectory> </dependency>
<sourceDirectory>src/java</sourceDirectory> </dependencies>
<testSourceDirectory>src/test</testSourceDirectory> <build>
<testResources> <directory>${build-directory}</directory>
<testResource> <outputDirectory>${build-directory}/classes/java</outputDirectory>
<directory>${project.build.testSourceDirectory}</directory> <testOutputDirectory>${build-directory}/classes/test</testOutputDirectory>
<excludes> <sourceDirectory>src/java</sourceDirectory>
<exclude>**/*.java</exclude> <testSourceDirectory>src/test</testSourceDirectory>
</excludes> <testResources>
</testResource> <testResource>
</testResources> <directory>${project.build.testSourceDirectory}</directory>
</build> <excludes>
</project> <exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
</build>
</project>

View File

@ -33,8 +33,9 @@
<modules> <modules>
<module>analysis</module> <module>analysis</module>
<module>benchmark</module> <module>benchmark</module>
<module>common</module> <module>facet</module>
<module>grouping</module> <module>grouping</module>
<module>join</module>
<module>queries</module> <module>queries</module>
<module>suggest</module> <module>suggest</module>
</modules> </modules>

View File

@ -41,11 +41,6 @@
<artifactId>lucene-core</artifactId> <artifactId>lucene-core</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>lucene-common-module</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>lucene-test-framework</artifactId> <artifactId>lucene-test-framework</artifactId>

View File

@ -41,7 +41,7 @@
<properties> <properties>
<base.specification.version>4.0.0</base.specification.version> <base.specification.version>4.0.0</base.specification.version>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format> <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
<java.compat.version>1.5</java.compat.version> <java.compat.version>1.6</java.compat.version>
<jetty.version>6.1.26</jetty.version> <jetty.version>6.1.26</jetty.version>
<patched.jetty.version>6.1.26-patched-JETTY-1340</patched.jetty.version> <patched.jetty.version>6.1.26-patched-JETTY-1340</patched.jetty.version>
<slf4j.version>1.6.1</slf4j.version> <slf4j.version>1.6.1</slf4j.version>
@ -280,6 +280,11 @@
<artifactId>carrot2-core</artifactId> <artifactId>carrot2-core</artifactId>
<version>3.5.0</version> <version>3.5.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.carrot2</groupId>
<artifactId>morfologik-polish</artifactId>
<version>1.5.2</version>
</dependency>
<dependency> <dependency>
<groupId>org.codehaus.woodstox</groupId> <groupId>org.codehaus.woodstox</groupId>
<artifactId>wstx-asl</artifactId> <artifactId>wstx-asl</artifactId>

View File

@ -101,11 +101,6 @@
<artifactId>lucene-grouping</artifactId> <artifactId>lucene-grouping</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-common-module</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.lucene</groupId> <groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries</artifactId> <artifactId>lucene-queries</artifactId>
@ -166,6 +161,11 @@
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId> <artifactId>slf4j-jdk14</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>wstx-asl</artifactId>
<scope>runtime</scope>
</dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId> <artifactId>servlet-api</artifactId>

View File

@ -215,9 +215,36 @@ def testChanges(project, version, changesURLString):
raise RuntimeError('did not see Contrib-Changes.html link from %s' % changesURLString) raise RuntimeError('did not see Contrib-Changes.html link from %s' % changesURLString)
s = load(changesURL) s = load(changesURL)
checkChangesContent(s, version, changesURL, project, True)
if s.find('Release %s' % version) == -1: def testChangesText(dir, version, project):
raise RuntimeError('did not see "Release %s" in %s' % (version, changesURL)) "Checks all CHANGES.txt under this dir."
for root, dirs, files in os.walk(dir):
# NOTE: O(N) but N should be smallish:
if 'CHANGES.txt' in files:
fullPath = '%s/CHANGES.txt' % root
print 'CHECK %s' % fullPath
checkChangesContent(open(fullPath).read(), version, fullPath, project, False)
def checkChangesContent(s, version, name, project, isHTML):
if isHTML and s.find('Release %s' % version) == -1:
raise RuntimeError('did not see "Release %s" in %s' % (version, name))
if s.lower().find('not yet released') != -1:
raise RuntimeError('saw "not yet released" in %s' % name)
if not isHTML:
if project == 'lucene':
sub = 'Lucene %s' % version
else:
sub = version
if s.find(sub) == -1:
# contrib/benchmark never seems to include release info:
if name.find('/benchmark/') == -1:
raise RuntimeError('did not see "%s" in %s' % (sub, name))
def run(command, logFile): def run(command, logFile):
if os.system('%s > %s 2>&1' % (command, logFile)): if os.system('%s > %s 2>&1' % (command, logFile)):
@ -340,6 +367,8 @@ def verifyUnpacked(project, artifact, unpackPath, version):
if project == 'lucene': if project == 'lucene':
testDemo(isSrc, version) testDemo(isSrc, version)
testChangesText('.', version, project)
def testDemo(isSrc, version): def testDemo(isSrc, version):
print ' test demo...' print ' test demo...'
if isSrc: if isSrc:

View File

@ -152,6 +152,10 @@ Changes in backwards compatibility policy
* LUCENE-2548: Field names (eg in Term, FieldInfo) are no longer * LUCENE-2548: Field names (eg in Term, FieldInfo) are no longer
interned. (Mike McCandless) interned. (Mike McCandless)
* LUCENE-2883: The contents of o.a.l.search.function has been consolidated into
the queries module and can be found at o.a.l.queries.function. See MIGRATE.txt
for more information (Chris Male)
Changes in Runtime Behavior Changes in Runtime Behavior
* LUCENE-2846: omitNorms now behaves like omitTermFrequencyAndPositions, if you * LUCENE-2846: omitNorms now behaves like omitTermFrequencyAndPositions, if you

View File

@ -364,3 +364,21 @@ LUCENE-1458, LUCENE-2111: Flexible Indexing
for applications that rely on Lucene's internal document ID for applications that rely on Lucene's internal document ID
assigment. If so, you should instead use LogByteSize/DocMergePolicy assigment. If so, you should instead use LogByteSize/DocMergePolicy
during indexing. during indexing.
* LUCENE-2883: Lucene's o.a.l.search.function ValueSource based functionality, was consolidated
into module/queries along with Solr's similar functionality. The following classes were moved:
- o.a.l.search.function.CustomScoreQuery -> o.a.l.queries.CustomScoreQuery
- o.a.l.search.function.CustomScoreProvider -> o.a.l.queries.CustomScoreProvider
- o.a.l.search.function.NumericIndexDocValueSource -> o.a.l.queries.function.valuesource.NumericIndexDocValueSource
The following lists the replacement classes for those removed:
- o.a.l.search.function.ByteFieldSource -> o.a.l.queries.function.valuesource.ByteFieldSource
- o.a.l.search.function.DocValues -> o.a.l.queries.function.DocValues
- o.a.l.search.function.FieldCacheSource -> o.a.l.queries.function.valuesource.FieldCacheSource
- o.a.l.search.function.FieldScoreQuery ->o.a.l.queries.function.FunctionQuery
- o.a.l.search.function.FloatFieldSource -> o.a.l.queries.function.valuesource.FloatFieldSource
- o.a.l.search.function.IntFieldSource -> o.a.l.queries.function.valuesource.IntFieldSource
- o.a.l.search.function.OrdFieldSource -> o.a.l.queries.function.valuesource.OrdFieldSource
- o.a.l.search.function.ReverseOrdFieldSource -> o.a.l.queries.function.valuesource.ReverseOrdFieldSource
- o.a.l.search.function.ShortFieldSource -> o.a.l.queries.function.valuesource.ShortFieldSource
- o.a.l.search.function.ValueSource -> o.a.l.queries.function.ValueSource
- o.a.l.search.function.ValueSourceQuery -> o.a.l.queries.function.FunctionQuery

View File

@ -95,15 +95,15 @@
<property name="javac.deprecation" value="off"/> <property name="javac.deprecation" value="off"/>
<property name="javac.debug" value="on"/> <property name="javac.debug" value="on"/>
<property name="javac.source" value="1.5"/> <property name="javac.source" value="1.6"/>
<property name="javac.target" value="1.5"/> <property name="javac.target" value="1.6"/>
<property name="javac.source.backwards" value="1.5"/> <property name="javac.source.backwards" value="1.6"/>
<property name="javac.target.backwards" value="1.5"/> <property name="javac.target.backwards" value="1.6"/>
<!-- clover wants to run with -lib, otherwise we prefer a repeatable <!-- clover wants to run with -lib, otherwise we prefer a repeatable
classpath --> classpath -->
<property name="javac.includeAntRuntime" value="${run.clover}"/> <property name="javac.includeAntRuntime" value="${run.clover}"/>
<property name="javadoc.link" value="http://java.sun.com/j2se/1.5/docs/api/"/> <property name="javadoc.link" value="http://download.oracle.com/javase/6/docs/api/"/>
<property name="javadoc.access" value="protected"/> <property name="javadoc.access" value="protected"/>
<property name="javadoc.charset" value="utf-8"/> <property name="javadoc.charset" value="utf-8"/>
<property name="javadoc.dir" value="${common.dir}/build/docs/api"/> <property name="javadoc.dir" value="${common.dir}/build/docs/api"/>
@ -844,8 +844,6 @@
<!-- Lucene --> <!-- Lucene -->
<arg value="-c" /> <arg value="-c" />
<arg value="${basedir}/lib" /> <arg value="${basedir}/lib" />
<arg value="-c" />
<arg value="${basedir}/contrib/queries/lib" />
</java> </java>
</target> </target>

View File

@ -65,7 +65,19 @@ New Features
* LUCENE-3234: provide a limit on phrase analysis in FastVectorHighlighter for * LUCENE-3234: provide a limit on phrase analysis in FastVectorHighlighter for
highlighting speed up. Use FastVectorHighlighter.setPhraseLimit() to set limit highlighting speed up. Use FastVectorHighlighter.setPhraseLimit() to set limit
(e.g. 5000). (Mike Sokolov via Koji Sekiguchi) (e.g. 5000). (Mike Sokolov via Koji Sekiguchi)
* LUCENE-3079: a new facet module which provides faceted indexing & search
capabilities. It allows managing a taxonomy of categories, and index them
with documents. It also provides search API for aggregating (e.g. count)
the weights of the categories that are relevant to the search results.
(Shai Erera)
* LUCENE-3171: Added BlockJoinQuery and BlockJoinCollector, under the
new contrib/join module, to enable searches that require joining
between parent and child documents. Joined (children + parent)
documents must be indexed as a document block, using
IndexWriter.add/UpdateDocuments (Mark Harwood, Mike McCandless)
API Changes API Changes
Bug Fixes Bug Fixes

View File

@ -75,7 +75,7 @@
property="pom.xml.present"> property="pom.xml.present">
</available> </available>
<target name="dist-maven" if="pom.xml.present" depends="compile-core, jar-src"> <target name="dist-maven" if="pom.xml.present" depends="jar-core, jar-src, javadocs">
<taskdef resource="org/apache/maven/artifact/ant/antlib.xml" <taskdef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant" uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath"/> classpathref="maven-ant-tasks.classpath"/>

View File

@ -34,8 +34,8 @@ import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo; import org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo;
/** /**
* FieldQuery breaks down query object into terms/phrases and keep * FieldQuery breaks down query object into terms/phrases and keeps
* them in QueryPhraseMap structure. * them in a QueryPhraseMap structure.
*/ */
public class FieldQuery { public class FieldQuery {

View File

@ -115,8 +115,7 @@ public class FieldTermStack {
* @param termInfo the TermInfo object to be put on the top of the stack * @param termInfo the TermInfo object to be put on the top of the stack
*/ */
public void push( TermInfo termInfo ){ public void push( TermInfo termInfo ){
// termList.push( termInfo ); // avoid Java 1.6 feature termList.push( termInfo );
termList.addFirst( termInfo );
} }
/** /**

View File

@ -23,13 +23,13 @@ import org.apache.lucene.util.BytesRef;
public class InstantiatedDocsAndPositionsEnum extends DocsAndPositionsEnum { public class InstantiatedDocsAndPositionsEnum extends DocsAndPositionsEnum {
private int upto; private int upto;
private int posUpto; private int posUpto;
private Bits skipDocs; private Bits liveDocs;
private InstantiatedTerm term; private InstantiatedTerm term;
protected InstantiatedTermDocumentInformation currentDoc; protected InstantiatedTermDocumentInformation currentDoc;
private final BytesRef payload = new BytesRef(); private final BytesRef payload = new BytesRef();
public InstantiatedDocsAndPositionsEnum reset(Bits skipDocs, InstantiatedTerm term) { public InstantiatedDocsAndPositionsEnum reset(Bits liveDocs, InstantiatedTerm term) {
this.skipDocs = skipDocs; this.liveDocs = liveDocs;
this.term = term; this.term = term;
upto = -1; upto = -1;
return this; return this;
@ -47,7 +47,7 @@ public class InstantiatedDocsAndPositionsEnum extends DocsAndPositionsEnum {
return NO_MORE_DOCS; return NO_MORE_DOCS;
} else { } else {
currentDoc = term.getAssociatedDocuments()[upto]; currentDoc = term.getAssociatedDocuments()[upto];
if (skipDocs == null || !skipDocs.get(currentDoc.getDocument().getDocumentNumber())) { if (liveDocs == null || liveDocs.get(currentDoc.getDocument().getDocumentNumber())) {
posUpto = -1; posUpto = -1;
return docID(); return docID();
} else { } else {
@ -69,7 +69,7 @@ public class InstantiatedDocsAndPositionsEnum extends DocsAndPositionsEnum {
} }
currentDoc = term.getAssociatedDocuments()[upto]; currentDoc = term.getAssociatedDocuments()[upto];
if (skipDocs != null && skipDocs.get(currentDoc.getDocument().getDocumentNumber())) { if (liveDocs != null && !liveDocs.get(currentDoc.getDocument().getDocumentNumber())) {
return nextDoc(); return nextDoc();
} else { } else {
posUpto = -1; posUpto = -1;

View File

@ -21,12 +21,12 @@ import org.apache.lucene.util.Bits;
public class InstantiatedDocsEnum extends DocsEnum { public class InstantiatedDocsEnum extends DocsEnum {
private int upto; private int upto;
private Bits skipDocs; private Bits liveDocs;
private InstantiatedTerm term; private InstantiatedTerm term;
protected InstantiatedTermDocumentInformation currentDoc; protected InstantiatedTermDocumentInformation currentDoc;
public InstantiatedDocsEnum reset(Bits skipDocs, InstantiatedTerm term) { public InstantiatedDocsEnum reset(Bits liveDocs, InstantiatedTerm term) {
this.skipDocs = skipDocs; this.liveDocs = liveDocs;
this.term = term; this.term = term;
upto = -1; upto = -1;
return this; return this;
@ -44,7 +44,7 @@ public class InstantiatedDocsEnum extends DocsEnum {
return NO_MORE_DOCS; return NO_MORE_DOCS;
} else { } else {
currentDoc = term.getAssociatedDocuments()[upto]; currentDoc = term.getAssociatedDocuments()[upto];
if (skipDocs == null || !skipDocs.get(currentDoc.getDocument().getDocumentNumber())) { if (liveDocs == null || liveDocs.get(currentDoc.getDocument().getDocumentNumber())) {
return docID(); return docID();
} else { } else {
return nextDoc(); return nextDoc();
@ -65,7 +65,7 @@ public class InstantiatedDocsEnum extends DocsEnum {
} }
currentDoc = term.getAssociatedDocuments()[upto]; currentDoc = term.getAssociatedDocuments()[upto];
if (skipDocs != null && skipDocs.get(currentDoc.getDocument().getDocumentNumber())) { if (liveDocs != null && !liveDocs.get(currentDoc.getDocument().getDocumentNumber())) {
return nextDoc(); return nextDoc();
} else { } else {
return docID(); return docID();

View File

@ -182,9 +182,9 @@ public class InstantiatedIndex
} }
// create documents // create documents
final Bits delDocs = MultiFields.getDeletedDocs(sourceIndexReader); final Bits liveDocs = MultiFields.getLiveDocs(sourceIndexReader);
for (int i = 0; i < sourceIndexReader.maxDoc(); i++) { for (int i = 0; i < sourceIndexReader.maxDoc(); i++) {
if (delDocs != null && delDocs.get(i)) { if (liveDocs != null && !liveDocs.get(i)) {
deletedDocuments.set(i); deletedDocuments.set(i);
} else { } else {
InstantiatedDocument document = new InstantiatedDocument(); InstantiatedDocument document = new InstantiatedDocument();
@ -254,7 +254,7 @@ public class InstantiatedIndex
// create term-document informations // create term-document informations
for (InstantiatedTerm term : orderedTerms) { for (InstantiatedTerm term : orderedTerms) {
DocsAndPositionsEnum termPositions = MultiFields.getTermPositionsEnum(sourceIndexReader, DocsAndPositionsEnum termPositions = MultiFields.getTermPositionsEnum(sourceIndexReader,
MultiFields.getDeletedDocs(sourceIndexReader), MultiFields.getLiveDocs(sourceIndexReader),
term.getTerm().field(), term.getTerm().field(),
new BytesRef(term.getTerm().text())); new BytesRef(term.getTerm().text()));
int position = 0; int position = 0;

View File

@ -107,11 +107,11 @@ public class InstantiatedIndexReader extends IndexReader {
} }
@Override @Override
public Bits getDeletedDocs() { public Bits getLiveDocs() {
return new Bits() { return new Bits() {
public boolean get(int n) { public boolean get(int n) {
return (index.getDeletedDocuments() != null && index.getDeletedDocuments().get(n)) return !(index.getDeletedDocuments() != null && index.getDeletedDocuments().get(n))
|| (uncommittedDeletedDocuments != null && uncommittedDeletedDocuments.get(n)); && !(uncommittedDeletedDocuments != null && uncommittedDeletedDocuments.get(n));
} }
public int length() { public int length() {

View File

@ -118,19 +118,19 @@ public class InstantiatedTermsEnum extends TermsEnum {
} }
@Override @Override
public DocsEnum docs(Bits skipDocs, DocsEnum reuse) { public DocsEnum docs(Bits liveDocs, DocsEnum reuse) {
if (reuse == null || !(reuse instanceof InstantiatedDocsEnum)) { if (reuse == null || !(reuse instanceof InstantiatedDocsEnum)) {
reuse = new InstantiatedDocsEnum(); reuse = new InstantiatedDocsEnum();
} }
return ((InstantiatedDocsEnum) reuse).reset(skipDocs, terms[upto]); return ((InstantiatedDocsEnum) reuse).reset(liveDocs, terms[upto]);
} }
@Override @Override
public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, DocsAndPositionsEnum reuse) { public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse) {
if (reuse == null || !(reuse instanceof InstantiatedDocsAndPositionsEnum)) { if (reuse == null || !(reuse instanceof InstantiatedDocsAndPositionsEnum)) {
reuse = new InstantiatedDocsAndPositionsEnum(); reuse = new InstantiatedDocsAndPositionsEnum();
} }
return ((InstantiatedDocsAndPositionsEnum) reuse).reset(skipDocs, terms[upto]); return ((InstantiatedDocsAndPositionsEnum) reuse).reset(liveDocs, terms[upto]);
} }
@Override @Override

View File

@ -138,8 +138,8 @@ public class TestIndicesEquals extends LuceneTestCase {
testTermEnum.seekCeil(new BytesRef(t.text())); testTermEnum.seekCeil(new BytesRef(t.text()));
assertEquals(aprioriTermEnum.term(), testTermEnum.term()); assertEquals(aprioriTermEnum.term(), testTermEnum.term());
DocsEnum aprioriTermDocs = aprioriTermEnum.docs(MultiFields.getDeletedDocs(aprioriReader), null); DocsEnum aprioriTermDocs = aprioriTermEnum.docs(MultiFields.getLiveDocs(aprioriReader), null);
DocsEnum testTermDocs = testTermEnum.docs(MultiFields.getDeletedDocs(testReader), null); DocsEnum testTermDocs = testTermEnum.docs(MultiFields.getLiveDocs(testReader), null);
assertEquals(aprioriTermDocs.nextDoc(), testTermDocs.nextDoc()); assertEquals(aprioriTermDocs.nextDoc(), testTermDocs.nextDoc());
assertEquals(aprioriTermDocs.freq(), testTermDocs.freq()); assertEquals(aprioriTermDocs.freq(), testTermDocs.freq());
@ -186,8 +186,8 @@ public class TestIndicesEquals extends LuceneTestCase {
assertEquals(aprioriTermEnum.next(), testTermEnum.next()); assertEquals(aprioriTermEnum.next(), testTermEnum.next());
aprioriTermDocs = aprioriTermEnum.docs(MultiFields.getDeletedDocs(aprioriReader), aprioriTermDocs); aprioriTermDocs = aprioriTermEnum.docs(MultiFields.getLiveDocs(aprioriReader), aprioriTermDocs);
testTermDocs = testTermEnum.docs(MultiFields.getDeletedDocs(testReader), testTermDocs); testTermDocs = testTermEnum.docs(MultiFields.getLiveDocs(testReader), testTermDocs);
while (aprioriTermDocs.nextDoc() != DocsEnum.NO_MORE_DOCS) { while (aprioriTermDocs.nextDoc() != DocsEnum.NO_MORE_DOCS) {
assertTrue(testTermDocs.nextDoc() != DocsEnum.NO_MORE_DOCS); assertTrue(testTermDocs.nextDoc() != DocsEnum.NO_MORE_DOCS);
@ -309,13 +309,13 @@ public class TestIndicesEquals extends LuceneTestCase {
assertEquals(air.numDocs(), tir.numDocs()); assertEquals(air.numDocs(), tir.numDocs());
assertEquals(air.numDeletedDocs(), tir.numDeletedDocs()); assertEquals(air.numDeletedDocs(), tir.numDeletedDocs());
final Bits aDelDocs = MultiFields.getDeletedDocs(air); final Bits aLiveDocs = MultiFields.getLiveDocs(air);
final Bits tDelDocs = MultiFields.getDeletedDocs(tir); final Bits tLiveDocs = MultiFields.getLiveDocs(tir);
assertTrue((aDelDocs != null && tDelDocs != null) || assertTrue((aLiveDocs != null && tLiveDocs != null) ||
(aDelDocs == null && tDelDocs == null)); (aLiveDocs == null && tLiveDocs == null));
if (aDelDocs != null) { if (aLiveDocs != null) {
for (int d =0; d<air.maxDoc(); d++) { for (int d =0; d<air.maxDoc(); d++) {
assertEquals(aDelDocs.get(d), tDelDocs.get(d)); assertEquals(aLiveDocs.get(d), tLiveDocs.get(d));
} }
} }
@ -366,13 +366,13 @@ public class TestIndicesEquals extends LuceneTestCase {
} }
} }
final Bits apDelDocs = MultiFields.getDeletedDocs(aprioriReader); final Bits apLiveDocs = MultiFields.getLiveDocs(aprioriReader);
final Bits testDelDocs = MultiFields.getDeletedDocs(testReader); final Bits testLiveDocs = MultiFields.getLiveDocs(testReader);
assertTrue((apDelDocs != null && testDelDocs != null) || assertTrue((apLiveDocs != null && testLiveDocs != null) ||
(apDelDocs == null && testDelDocs == null)); (apLiveDocs == null && testLiveDocs == null));
if (apDelDocs != null) { if (apLiveDocs != null) {
for (int docIndex = 0; docIndex < aprioriReader.numDocs(); docIndex++) { for (int docIndex = 0; docIndex < aprioriReader.numDocs(); docIndex++) {
assertEquals(apDelDocs.get(docIndex), testDelDocs.get(docIndex)); assertEquals(apLiveDocs.get(docIndex), testLiveDocs.get(docIndex));
} }
} }
@ -407,8 +407,8 @@ public class TestIndicesEquals extends LuceneTestCase {
// compare termDocs seeking // compare termDocs seeking
DocsEnum aprioriTermDocs = aprioriTermEnum.docs(MultiFields.getDeletedDocs(aprioriReader), null); DocsEnum aprioriTermDocs = aprioriTermEnum.docs(MultiFields.getLiveDocs(aprioriReader), null);
DocsEnum testTermDocs = testTermEnum.docs(MultiFields.getDeletedDocs(testReader), null); DocsEnum testTermDocs = testTermEnum.docs(MultiFields.getLiveDocs(testReader), null);
while (aprioriTermDocs.nextDoc() != DocsEnum.NO_MORE_DOCS) { while (aprioriTermDocs.nextDoc() != DocsEnum.NO_MORE_DOCS) {
assertTrue(testTermDocs.advance(aprioriTermDocs.docID()) != DocsEnum.NO_MORE_DOCS); assertTrue(testTermDocs.advance(aprioriTermDocs.docID()) != DocsEnum.NO_MORE_DOCS);
@ -419,8 +419,8 @@ public class TestIndicesEquals extends LuceneTestCase {
assertEquals(aprioriReader.docFreq(aprioriField, aprioriTermEnum.term()), testReader.docFreq(aprioriField, testTermEnum.term())); assertEquals(aprioriReader.docFreq(aprioriField, aprioriTermEnum.term()), testReader.docFreq(aprioriField, testTermEnum.term()));
aprioriTermDocs = aprioriTermEnum.docs(MultiFields.getDeletedDocs(aprioriReader), aprioriTermDocs); aprioriTermDocs = aprioriTermEnum.docs(MultiFields.getLiveDocs(aprioriReader), aprioriTermDocs);
testTermDocs = testTermEnum.docs(MultiFields.getDeletedDocs(testReader), testTermDocs); testTermDocs = testTermEnum.docs(MultiFields.getLiveDocs(testReader), testTermDocs);
while (true) { while (true) {
if (aprioriTermDocs.nextDoc() == DocsEnum.NO_MORE_DOCS) { if (aprioriTermDocs.nextDoc() == DocsEnum.NO_MORE_DOCS) {
@ -439,8 +439,8 @@ public class TestIndicesEquals extends LuceneTestCase {
// compare term positions // compare term positions
DocsAndPositionsEnum aprioriTermPositions = aprioriTermEnum.docsAndPositions(MultiFields.getDeletedDocs(aprioriReader), null); DocsAndPositionsEnum aprioriTermPositions = aprioriTermEnum.docsAndPositions(MultiFields.getLiveDocs(aprioriReader), null);
DocsAndPositionsEnum testTermPositions = testTermEnum.docsAndPositions(MultiFields.getDeletedDocs(testReader), null); DocsAndPositionsEnum testTermPositions = testTermEnum.docsAndPositions(MultiFields.getLiveDocs(testReader), null);
if (VERBOSE) { if (VERBOSE) {
System.out.println("TEST: enum1=" + aprioriTermPositions + " enum2=" + testTermPositions); System.out.println("TEST: enum1=" + aprioriTermPositions + " enum2=" + testTermPositions);

View File

@ -53,8 +53,9 @@ public class TestUnoptimizedReaderOnConstructor extends LuceneTestCase {
unoptimizedReader.deleteDocument(2); unoptimizedReader.deleteDocument(2);
try { try {
new InstantiatedIndex(unoptimizedReader); new InstantiatedIndex(unoptimizedReader);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(System.out);
fail("No exceptions when loading an unoptimized reader!"); fail("No exceptions when loading an unoptimized reader!");
} }

View File

@ -769,7 +769,7 @@ public class MemoryIndex {
} }
@Override @Override
public Bits getDeletedDocs() { public Bits getLiveDocs() {
return null; return null;
} }
@ -925,19 +925,19 @@ public class MemoryIndex {
} }
@Override @Override
public DocsEnum docs(Bits skipDocs, DocsEnum reuse) { public DocsEnum docs(Bits liveDocs, DocsEnum reuse) {
if (reuse == null || !(reuse instanceof MemoryDocsEnum)) { if (reuse == null || !(reuse instanceof MemoryDocsEnum)) {
reuse = new MemoryDocsEnum(); reuse = new MemoryDocsEnum();
} }
return ((MemoryDocsEnum) reuse).reset(skipDocs, info.sortedTerms[termUpto].getValue()); return ((MemoryDocsEnum) reuse).reset(liveDocs, info.sortedTerms[termUpto].getValue());
} }
@Override @Override
public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, DocsAndPositionsEnum reuse) { public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse) {
if (reuse == null || !(reuse instanceof MemoryDocsAndPositionsEnum)) { if (reuse == null || !(reuse instanceof MemoryDocsAndPositionsEnum)) {
reuse = new MemoryDocsAndPositionsEnum(); reuse = new MemoryDocsAndPositionsEnum();
} }
return ((MemoryDocsAndPositionsEnum) reuse).reset(skipDocs, info.sortedTerms[termUpto].getValue()); return ((MemoryDocsAndPositionsEnum) reuse).reset(liveDocs, info.sortedTerms[termUpto].getValue());
} }
@Override @Override
@ -962,10 +962,10 @@ public class MemoryIndex {
private class MemoryDocsEnum extends DocsEnum { private class MemoryDocsEnum extends DocsEnum {
private ArrayIntList positions; private ArrayIntList positions;
private boolean hasNext; private boolean hasNext;
private Bits skipDocs; private Bits liveDocs;
public DocsEnum reset(Bits skipDocs, ArrayIntList positions) { public DocsEnum reset(Bits liveDocs, ArrayIntList positions) {
this.skipDocs = skipDocs; this.liveDocs = liveDocs;
this.positions = positions; this.positions = positions;
hasNext = true; hasNext = true;
return this; return this;
@ -978,7 +978,7 @@ public class MemoryIndex {
@Override @Override
public int nextDoc() { public int nextDoc() {
if (hasNext && (skipDocs == null || !skipDocs.get(0))) { if (hasNext && (liveDocs == null || liveDocs.get(0))) {
hasNext = false; hasNext = false;
return 0; return 0;
} else { } else {
@ -1001,10 +1001,10 @@ public class MemoryIndex {
private ArrayIntList positions; private ArrayIntList positions;
private int posUpto; private int posUpto;
private boolean hasNext; private boolean hasNext;
private Bits skipDocs; private Bits liveDocs;
public DocsAndPositionsEnum reset(Bits skipDocs, ArrayIntList positions) { public DocsAndPositionsEnum reset(Bits liveDocs, ArrayIntList positions) {
this.skipDocs = skipDocs; this.liveDocs = liveDocs;
this.positions = positions; this.positions = positions;
posUpto = 0; posUpto = 0;
hasNext = true; hasNext = true;
@ -1018,7 +1018,7 @@ public class MemoryIndex {
@Override @Override
public int nextDoc() { public int nextDoc() {
if (hasNext && (skipDocs == null || !skipDocs.get(0))) { if (hasNext && (liveDocs == null || liveDocs.get(0))) {
hasNext = false; hasNext = false;
return 0; return 0;
} else { } else {

View File

@ -120,7 +120,7 @@ public class FieldNormModifier {
final FieldInvertState invertState = new FieldInvertState(); final FieldInvertState invertState = new FieldInvertState();
for(IndexReader subReader : subReaders) { for(IndexReader subReader : subReaders) {
final Bits delDocs = subReader.getDeletedDocs(); final Bits liveDocs = subReader.getLiveDocs();
int[] termCounts = new int[subReader.maxDoc()]; int[] termCounts = new int[subReader.maxDoc()];
Fields fields = subReader.fields(); Fields fields = subReader.fields();
@ -130,7 +130,7 @@ public class FieldNormModifier {
TermsEnum termsEnum = terms.iterator(); TermsEnum termsEnum = terms.iterator();
DocsEnum docs = null; DocsEnum docs = null;
while(termsEnum.next() != null) { while(termsEnum.next() != null) {
docs = termsEnum.docs(delDocs, docs); docs = termsEnum.docs(liveDocs, docs);
while(true) { while(true) {
int docID = docs.nextDoc(); int docID = docs.nextDoc();
if (docID != docs.NO_MORE_DOCS) { if (docID != docs.NO_MORE_DOCS) {
@ -145,7 +145,7 @@ public class FieldNormModifier {
invertState.setBoost(1.0f); invertState.setBoost(1.0f);
for (int d = 0; d < termCounts.length; d++) { for (int d = 0; d < termCounts.length; d++) {
if (delDocs == null || !delDocs.get(d)) { if (liveDocs == null || liveDocs.get(d)) {
invertState.setLength(termCounts[d]); invertState.setLength(termCounts[d]);
subReader.setNorm(d, field, fieldSim.encodeNormValue(fieldSim.computeNorm(invertState))); subReader.setNorm(d, field, fieldSim.encodeNormValue(fieldSim.computeNorm(invertState)));
} }

View File

@ -25,8 +25,8 @@ import org.apache.lucene.index.IndexWriter; // javadoc
import org.apache.lucene.index.IndexWriterConfig.OpenMode; import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory; import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory; import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.OpenBitSet;
import org.apache.lucene.util.Bits; import org.apache.lucene.util.Bits;
import org.apache.lucene.util.OpenBitSet;
import org.apache.lucene.util.Version; import org.apache.lucene.util.Version;
/** /**
@ -177,27 +177,17 @@ public class MultiPassIndexSplitter {
* Instead, deletions are buffered in a bitset and overlaid with the original * Instead, deletions are buffered in a bitset and overlaid with the original
* list of deletions. * list of deletions.
*/ */
public static class FakeDeleteIndexReader extends FilterIndexReader { public static final class FakeDeleteIndexReader extends FilterIndexReader {
OpenBitSet dels; OpenBitSet liveDocs;
OpenBitSet oldDels = null;
public FakeDeleteIndexReader(IndexReader in) { public FakeDeleteIndexReader(IndexReader in) {
super(new SlowMultiReaderWrapper(in)); super(new SlowMultiReaderWrapper(in));
dels = new OpenBitSet(in.maxDoc()); doUndeleteAll(); // initialize main bitset
if (in.hasDeletions()) {
oldDels = new OpenBitSet(in.maxDoc());
final Bits oldDelBits = MultiFields.getDeletedDocs(in);
assert oldDelBits != null;
for (int i = 0; i < in.maxDoc(); i++) {
if (oldDelBits.get(i)) oldDels.set(i);
}
dels.or(oldDels);
}
} }
@Override @Override
public int numDocs() { public int numDocs() {
return in.maxDoc() - (int)dels.cardinality(); return (int) liveDocs.cardinality();
} }
/** /**
@ -205,26 +195,35 @@ public class MultiPassIndexSplitter {
* deletions. * deletions.
*/ */
@Override @Override
protected void doUndeleteAll() throws CorruptIndexException, IOException { protected void doUndeleteAll() {
dels = new OpenBitSet(in.maxDoc()); final int maxDoc = in.maxDoc();
if (oldDels != null) { liveDocs = new OpenBitSet(maxDoc);
dels.or(oldDels); if (in.hasDeletions()) {
final Bits oldLiveDocs = in.getLiveDocs();
assert oldLiveDocs != null;
// this loop is a little bit ineffective, as Bits has no nextSetBit():
for (int i = 0; i < maxDoc; i++) {
if (oldLiveDocs.get(i)) liveDocs.fastSet(i);
}
} else {
// mark all docs as valid
liveDocs.set(0, maxDoc);
} }
} }
@Override @Override
protected void doDelete(int n) throws CorruptIndexException, IOException { protected void doDelete(int n) {
dels.set(n); liveDocs.clear(n);
} }
@Override @Override
public boolean hasDeletions() { public boolean hasDeletions() {
return !dels.isEmpty(); return (in.maxDoc() != this.numDocs());
} }
@Override @Override
public Bits getDeletedDocs() { public Bits getLiveDocs() {
return dels; return liveDocs;
} }
} }
} }

View File

@ -351,7 +351,7 @@ public class NRTManager implements Closeable {
} }
/** NOTE: caller must separately close the writer. */ /** NOTE: caller must separately close the writer. */
// @Override -- not until Java 1.6 @Override
public void close() throws IOException { public void close() throws IOException {
swapSearcher(null, indexingGen.getAndIncrement(), true); swapSearcher(null, indexingGen.getAndIncrement(), true);
} }

View File

@ -19,16 +19,16 @@ package org.apache.lucene.index;
import java.io.IOException; import java.io.IOException;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.IndexReader.AtomicReaderContext; import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.store.Directory; import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Filter; import org.apache.lucene.search.Filter;
import org.apache.lucene.search.TermRangeFilter; import org.apache.lucene.search.TermRangeFilter;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Bits; import org.apache.lucene.util.Bits;
import org.apache.lucene.util.OpenBitSetDISI;
import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.OpenBitSetDISI;
import org.apache.lucene.util.Version; import org.apache.lucene.util.Version;
/** /**
@ -87,13 +87,14 @@ public class PKIndexSplitter {
} }
public static class DocumentFilteredIndexReader extends FilterIndexReader { public static class DocumentFilteredIndexReader extends FilterIndexReader {
final Bits readerDels; final Bits liveDocs;
final int numDocs; final int numDocs;
public DocumentFilteredIndexReader(IndexReader reader, Filter preserveFilter, boolean negateFilter) throws IOException { public DocumentFilteredIndexReader(IndexReader reader, Filter preserveFilter, boolean negateFilter) throws IOException {
super(new SlowMultiReaderWrapper(reader)); super(new SlowMultiReaderWrapper(reader));
final OpenBitSetDISI bits = new OpenBitSetDISI(in.maxDoc()); final int maxDoc = in.maxDoc();
final OpenBitSetDISI bits = new OpenBitSetDISI(maxDoc);
final DocIdSet docs = preserveFilter.getDocIdSet((AtomicReaderContext) in.getTopReaderContext()); final DocIdSet docs = preserveFilter.getDocIdSet((AtomicReaderContext) in.getTopReaderContext());
if (docs != null) { if (docs != null) {
final DocIdSetIterator it = docs.iterator(); final DocIdSetIterator it = docs.iterator();
@ -101,23 +102,24 @@ public class PKIndexSplitter {
bits.inPlaceOr(it); bits.inPlaceOr(it);
} }
} }
// this is somehow inverse, if we negate the filter, we delete all documents it matches! if (negateFilter) {
if (!negateFilter) { bits.flip(0, maxDoc);
bits.flip(0, in.maxDoc());
} }
if (in.hasDeletions()) { if (in.hasDeletions()) {
final Bits oldDelBits = in.getDeletedDocs(); final Bits oldLiveDocs = in.getLiveDocs();
assert oldDelBits != null; assert oldLiveDocs != null;
for (int i = 0; i < in.maxDoc(); i++) { final DocIdSetIterator it = bits.iterator();
if (oldDelBits.get(i)) { for (int i = it.nextDoc(); i < maxDoc; i = it.nextDoc()) {
bits.set(i); if (!oldLiveDocs.get(i)) {
// we can safely modify the current bit, as the iterator already stepped over it:
bits.fastClear(i);
} }
} }
} }
this.readerDels = bits; this.liveDocs = bits;
this.numDocs = in.maxDoc() - (int) bits.cardinality(); this.numDocs = (int) bits.cardinality();
} }
@Override @Override
@ -131,8 +133,8 @@ public class PKIndexSplitter {
} }
@Override @Override
public Bits getDeletedDocs() { public Bits getLiveDocs() {
return readerDels; return liveDocs;
} }
} }
} }

View File

@ -96,7 +96,7 @@ public class TermVectorAccessor {
positions.clear(); positions.clear();
} }
final Bits delDocs = MultiFields.getDeletedDocs(indexReader); final Bits liveDocs = MultiFields.getLiveDocs(indexReader);
Terms terms = MultiFields.getTerms(indexReader, field); Terms terms = MultiFields.getTerms(indexReader, field);
boolean anyTerms = false; boolean anyTerms = false;
@ -109,9 +109,9 @@ public class TermVectorAccessor {
if (text != null) { if (text != null) {
anyTerms = true; anyTerms = true;
if (!mapper.isIgnoringPositions()) { if (!mapper.isIgnoringPositions()) {
docs = postings = termsEnum.docsAndPositions(delDocs, postings); docs = postings = termsEnum.docsAndPositions(liveDocs, postings);
} else { } else {
docs = termsEnum.docs(delDocs, docs); docs = termsEnum.docs(liveDocs, docs);
} }
int docID = docs.advance(documentNumber); int docID = docs.advance(documentNumber);

View File

@ -190,8 +190,8 @@ public class HighFreqTerms {
return 0; return 0;
} }
Bits skipDocs = MultiFields.getDeletedDocs(reader); Bits liveDocs = MultiFields.getLiveDocs(reader);
if (skipDocs == null) { if (liveDocs == null) {
// TODO: we could do this up front, during the scan // TODO: we could do this up front, during the scan
// (next()), instead of after-the-fact here w/ seek, // (next()), instead of after-the-fact here w/ seek,
// if the codec supports it and there are no del // if the codec supports it and there are no del
@ -202,7 +202,7 @@ public class HighFreqTerms {
} }
} }
DocsEnum de = termsEnum.docs(skipDocs, null); DocsEnum de = termsEnum.docs(liveDocs, null);
// use DocsEnum.read() and BulkResult api // use DocsEnum.read() and BulkResult api
final DocsEnum.BulkReadResult bulkresult = de.getBulkResult(); final DocsEnum.BulkReadResult bulkresult = de.getBulkResult();

View File

@ -134,11 +134,11 @@ public class TestNRTManager extends LuceneTestCase {
System.out.println("TEST: now warm merged reader=" + reader); System.out.println("TEST: now warm merged reader=" + reader);
} }
final int maxDoc = reader.maxDoc(); final int maxDoc = reader.maxDoc();
final Bits delDocs = reader.getDeletedDocs(); final Bits liveDocs = reader.getLiveDocs();
int sum = 0; int sum = 0;
final int inc = Math.max(1, maxDoc/50); final int inc = Math.max(1, maxDoc/50);
for(int docID=0;docID<maxDoc;docID += inc) { for(int docID=0;docID<maxDoc;docID += inc) {
if (delDocs == null || !delDocs.get(docID)) { if (liveDocs == null || liveDocs.get(docID)) {
final Document doc = reader.document(docID); final Document doc = reader.document(docID);
sum += doc.getFields().size(); sum += doc.getFields().size();
} }

View File

@ -87,9 +87,9 @@ public class TestPKIndexSplitter extends LuceneTestCase {
} }
private void checkContents(IndexReader ir, String indexname) throws Exception { private void checkContents(IndexReader ir, String indexname) throws Exception {
final Bits delDocs = MultiFields.getDeletedDocs(ir); final Bits liveDocs = MultiFields.getLiveDocs(ir);
for (int i = 0; i < ir.maxDoc(); i++) { for (int i = 0; i < ir.maxDoc(); i++) {
if (delDocs == null || !delDocs.get(i)) { if (liveDocs == null || liveDocs.get(i)) {
assertEquals(indexname, ir.document(i).get("indexname")); assertEquals(indexname, ir.document(i).get("indexname"));
} }
} }

View File

@ -86,7 +86,7 @@ public class DuplicateFilter extends Filter
private OpenBitSet correctBits(IndexReader reader) throws IOException { private OpenBitSet correctBits(IndexReader reader) throws IOException {
OpenBitSet bits = new OpenBitSet(reader.maxDoc()); //assume all are INvalid OpenBitSet bits = new OpenBitSet(reader.maxDoc()); //assume all are INvalid
final Bits delDocs = MultiFields.getDeletedDocs(reader); final Bits liveDocs = MultiFields.getLiveDocs(reader);
Terms terms = reader.fields().terms(fieldName); Terms terms = reader.fields().terms(fieldName);
if (terms != null) { if (terms != null) {
TermsEnum termsEnum = terms.iterator(); TermsEnum termsEnum = terms.iterator();
@ -96,7 +96,7 @@ public class DuplicateFilter extends Filter
if (currTerm == null) { if (currTerm == null) {
break; break;
} else { } else {
docs = termsEnum.docs(delDocs, docs); docs = termsEnum.docs(liveDocs, docs);
int doc = docs.nextDoc(); int doc = docs.nextDoc();
if (doc != DocsEnum.NO_MORE_DOCS) { if (doc != DocsEnum.NO_MORE_DOCS) {
if (keepMode == KM_USE_FIRST_OCCURRENCE) { if (keepMode == KM_USE_FIRST_OCCURRENCE) {
@ -124,7 +124,7 @@ public class DuplicateFilter extends Filter
OpenBitSet bits=new OpenBitSet(reader.maxDoc()); OpenBitSet bits=new OpenBitSet(reader.maxDoc());
bits.set(0,reader.maxDoc()); //assume all are valid bits.set(0,reader.maxDoc()); //assume all are valid
final Bits delDocs = MultiFields.getDeletedDocs(reader); final Bits liveDocs = MultiFields.getLiveDocs(reader);
Terms terms = reader.fields().terms(fieldName); Terms terms = reader.fields().terms(fieldName);
if (terms != null) { if (terms != null) {
TermsEnum termsEnum = terms.iterator(); TermsEnum termsEnum = terms.iterator();
@ -136,7 +136,7 @@ public class DuplicateFilter extends Filter
} else { } else {
if (termsEnum.docFreq() > 1) { if (termsEnum.docFreq() > 1) {
// unset potential duplicates // unset potential duplicates
docs = termsEnum.docs(delDocs, docs); docs = termsEnum.docs(liveDocs, docs);
int doc = docs.nextDoc(); int doc = docs.nextDoc();
if (doc != DocsEnum.NO_MORE_DOCS) { if (doc != DocsEnum.NO_MORE_DOCS) {
if (keepMode == KM_USE_FIRST_OCCURRENCE) { if (keepMode == KM_USE_FIRST_OCCURRENCE) {

View File

@ -63,7 +63,7 @@ public class TermsFilter extends Filter
OpenBitSet result=new OpenBitSet(reader.maxDoc()); OpenBitSet result=new OpenBitSet(reader.maxDoc());
Fields fields = reader.fields(); Fields fields = reader.fields();
BytesRef br = new BytesRef(); BytesRef br = new BytesRef();
Bits delDocs = reader.getDeletedDocs(); Bits liveDocs = reader.getLiveDocs();
if (fields != null) { if (fields != null) {
String lastField = null; String lastField = null;
Terms termsC = null; Terms termsC = null;
@ -80,7 +80,7 @@ public class TermsFilter extends Filter
if (terms != null) { if (terms != null) {
br.copy(term.bytes()); br.copy(term.bytes());
if (termsEnum.seekCeil(br) == TermsEnum.SeekStatus.FOUND) { if (termsEnum.seekCeil(br) == TermsEnum.SeekStatus.FOUND) {
docs = termsEnum.docs(delDocs, docs); docs = termsEnum.docs(liveDocs, docs);
while(docs.nextDoc() != DocsEnum.NO_MORE_DOCS) { while(docs.nextDoc() != DocsEnum.NO_MORE_DOCS) {
result.set(docs.docID()); result.set(docs.docID());
} }

View File

@ -139,7 +139,7 @@ public class DuplicateFilterTest extends LuceneTestCase {
Document d=searcher.doc(hits[i].doc); Document d=searcher.doc(hits[i].doc);
String url=d.get(KEY_FIELD); String url=d.get(KEY_FIELD);
DocsEnum td = MultiFields.getTermDocsEnum(reader, DocsEnum td = MultiFields.getTermDocsEnum(reader,
MultiFields.getDeletedDocs(reader), MultiFields.getLiveDocs(reader),
KEY_FIELD, KEY_FIELD,
new BytesRef(url)); new BytesRef(url));
int lastDoc=0; int lastDoc=0;
@ -163,7 +163,7 @@ public class DuplicateFilterTest extends LuceneTestCase {
Document d=searcher.doc(hits[i].doc); Document d=searcher.doc(hits[i].doc);
String url=d.get(KEY_FIELD); String url=d.get(KEY_FIELD);
DocsEnum td = MultiFields.getTermDocsEnum(reader, DocsEnum td = MultiFields.getTermDocsEnum(reader,
MultiFields.getDeletedDocs(reader), MultiFields.getLiveDocs(reader),
KEY_FIELD, KEY_FIELD,
new BytesRef(url)); new BytesRef(url));
int lastDoc=0; int lastDoc=0;

View File

@ -0,0 +1,118 @@
package org.apache.lucene.queryParser.core.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.HashMap;
/**
* <p>
* This class is the base of {@link QueryConfigHandler} and {@link FieldConfig}.
* It has operations to set, unset and get configuration values.
* </p>
* <p>
* Each configuration is is a key->value pair. The key should be an unique
* {@link ConfigurationKey} instance and it also holds the value's type.
* </p>
*
* @see ConfigurationKey
*/
public abstract class AbstractQueryConfig {
final private HashMap<ConfigurationKey<?>, Object> configMap = new HashMap<ConfigurationKey<?>, Object>();
AbstractQueryConfig() {
// although this class is public, it can only be constructed from package
}
/**
* Returns the value held by the given key.
*
* @param <T> the value's type
*
* @param key the key, cannot be <code>null</code>
*
* @return the value held by the given key
*/
@SuppressWarnings("unchecked")
public <T> T get(ConfigurationKey<T> key) {
if (key == null) {
throw new IllegalArgumentException("key cannot be null!");
}
return (T) this.configMap.get(key);
}
/**
* Returns true if there is a value set with the given key, otherwise false.
*
* @param <T> @param <T> the value's type
* @param key the key, cannot be <code>null</code>
* @return true if there is a value set with the given key, otherwise false
*/
public <T> boolean has(ConfigurationKey<T> key) {
if (key == null) {
throw new IllegalArgumentException("key cannot be null!");
}
return this.configMap.containsKey(key);
}
/**
* Sets a key and its value.
*
* @param <T> the value's type
* @param key the key, cannot be <code>null</code>
* @param value
*/
public <T> void set(ConfigurationKey<T> key, T value) {
if (key == null) {
throw new IllegalArgumentException("key cannot be null!");
}
if (value == null) {
unset(key);
} else {
this.configMap.put(key, value);
}
}
/**
* Unsets the given key and its value.
*
* @param <T> the value's type
* @param key the key
* @return true if the key and value was set and removed, otherwise false
*/
public <T> boolean unset(ConfigurationKey<T> key) {
if (key == null) {
throw new IllegalArgumentException("key cannot be null!");
}
return this.configMap.remove(key) != null;
}
}

View File

@ -0,0 +1,42 @@
package org.apache.lucene.queryParser.core.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* An instance of this class represents a key that is used to retrieve a value
* from {@link AbstractQueryConfig}. It also holds the value's type, which is
* defined in the generic argument.
*
* @see AbstractQueryConfig
*/
final public class ConfigurationKey<T> {
private ConfigurationKey() {}
/**
* Creates a new instance.
*
* @param <T> the value's type
*
* @return a new instance
*/
public static <T> ConfigurationKey<T> newInstance() {
return new ConfigurationKey<T>();
}
}

View File

@ -17,16 +17,10 @@ package org.apache.lucene.queryParser.core.config;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.lucene.util.AttributeSource;
/** /**
* This class represents a field configuration. Every configuration should be * This class represents a field configuration.
* set using the methods inherited from {@link AttributeSource}.
*
* @see QueryConfigHandler
* @see org.apache.lucene.util.Attribute
*/ */
public class FieldConfig extends AttributeSource { public class FieldConfig extends AbstractQueryConfig {
private String fieldName; private String fieldName;
@ -57,7 +51,7 @@ public class FieldConfig extends AttributeSource {
@Override @Override
public String toString() { public String toString() {
return "<fieldconfig name=\"" + this.fieldName + "\" attributes=\"" return "<fieldconfig name=\"" + this.fieldName + "\" configurations=\""
+ super.toString() + "\"/>"; + super.toString() + "\"/>";
} }

View File

@ -20,7 +20,7 @@ package org.apache.lucene.queryParser.core.config;
/** /**
* This interface should be implemented by classes that wants to listen for * This interface should be implemented by classes that wants to listen for
* field configuration requests. The implementation receives a * field configuration requests. The implementation receives a
* {@link FieldConfig} object and may add/change its attributes. * {@link FieldConfig} object and may add/change its configuration.
* *
* @see FieldConfig * @see FieldConfig
* @see QueryConfigHandler * @see QueryConfigHandler

View File

@ -20,33 +20,28 @@ package org.apache.lucene.queryParser.core.config;
import java.util.LinkedList; import java.util.LinkedList;
import org.apache.lucene.queryParser.core.processors.QueryNodeProcessor; import org.apache.lucene.queryParser.core.processors.QueryNodeProcessor;
import org.apache.lucene.util.Attribute; import org.apache.lucene.queryParser.core.util.StringUtils;
import org.apache.lucene.util.AttributeSource;
/** /**
* This class can be used to hold any query configuration and no field * This class can be used to hold any query configuration and no field
* configuration. For field configuration, it creates a empty * configuration. For field configuration, it creates an empty
* {@link FieldConfig} object and delegate it to field config listeners, * {@link FieldConfig} object and delegate it to field config listeners,
* these are responsible for setting up all the field configuration. * these are responsible for setting up all the field configuration.
* *
* {@link QueryConfigHandler} should be extended by classes that intends to * {@link QueryConfigHandler} should be extended by classes that intends to
* provide configuration to {@link QueryNodeProcessor} objects. * provide configuration to {@link QueryNodeProcessor} objects.
* *
* This class extends {@link AttributeSource}, so {@link Attribute}s can be
* attached to it.
*
* The class that extends {@link QueryConfigHandler} should also provide * The class that extends {@link QueryConfigHandler} should also provide
* {@link FieldConfig} objects for each collection field. * {@link FieldConfig} objects for each collection field.
* *
* @see Attribute
* @see FieldConfig * @see FieldConfig
* @see FieldConfigListener * @see FieldConfigListener
* @see QueryConfigHandler * @see QueryConfigHandler
*/ */
public abstract class QueryConfigHandler extends AttributeSource { public abstract class QueryConfigHandler extends AbstractQueryConfig {
private LinkedList<FieldConfigListener> listeners = new LinkedList<FieldConfigListener>();
final private LinkedList<FieldConfigListener> listeners = new LinkedList<FieldConfigListener>();
/** /**
* Returns an implementation of * Returns an implementation of
* {@link FieldConfig} for a specific field name. If the implemented * {@link FieldConfig} for a specific field name. If the implemented
@ -61,7 +56,7 @@ public abstract class QueryConfigHandler extends AttributeSource {
* {@link QueryConfigHandler} has no configuration for that field * {@link QueryConfigHandler} has no configuration for that field
*/ */
public FieldConfig getFieldConfig(String fieldName) { public FieldConfig getFieldConfig(String fieldName) {
FieldConfig fieldConfig = new FieldConfig(fieldName); FieldConfig fieldConfig = new FieldConfig(StringUtils.toString(fieldName));
for (FieldConfigListener listener : this.listeners) { for (FieldConfigListener listener : this.listeners) {
listener.buildFieldConfig(fieldConfig); listener.buildFieldConfig(fieldConfig);

View File

@ -33,14 +33,7 @@ See {@link org.apache.lucene.queryParser.standard.config.StandardQueryConfigHand
implementation. implementation.
</p> </p>
<p> <p>
{@link org.apache.lucene.queryParser.core.config.FieldConfig} and {@link org.apache.lucene.queryParser.core.config.QueryConfigHandler} The {@link org.apache.lucene.queryParser.core.config.QueryConfigHandler} and {@link org.apache.lucene.queryParser.core.config.FieldConfig} are used in the processors to access config
should use {@link org.apache.lucene.util.Attribute} to store all attributes
required by the config implementation. See <tt>org.apache.lucene.queryParser.standard.config.*Attribute</tt>
for reference implementation.
</p>
<p>
The {@link org.apache.lucene.queryParser.core.config.QueryConfigHandler}, {@link org.apache.lucene.queryParser.core.config.FieldConfig},
and {@link org.apache.lucene.util.Attribute}s are used in the processors to access config
information in a flexible and independent way. information in a flexible and independent way.
See {@link org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor} for a See {@link org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor} for a
reference implementation. reference implementation.

View File

@ -29,8 +29,9 @@ import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.core.nodes.ModifierQueryNode.Modifier; import org.apache.lucene.queryParser.core.nodes.ModifierQueryNode.Modifier;
import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl;
import org.apache.lucene.queryParser.precedence.PrecedenceQueryParser; import org.apache.lucene.queryParser.precedence.PrecedenceQueryParser;
import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute.Operator; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.Operator;
/** /**
* <p> * <p>
@ -44,7 +45,7 @@ import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute.Op
* if it is, the same operation when an {@link AndQueryNode} is found is applied to it. * if it is, the same operation when an {@link AndQueryNode} is found is applied to it.
* </p> * </p>
* *
* @see DefaultOperatorAttribute * @see ConfigurationKeys#DEFAULT_OPERATOR
* @see PrecedenceQueryParser#setDefaultOperator * @see PrecedenceQueryParser#setDefaultOperator
*/ */
public class BooleanModifiersQueryNodeProcessor extends QueryNodeProcessorImpl { public class BooleanModifiersQueryNodeProcessor extends QueryNodeProcessorImpl {
@ -59,14 +60,14 @@ public class BooleanModifiersQueryNodeProcessor extends QueryNodeProcessorImpl {
@Override @Override
public QueryNode process(QueryNode queryTree) throws QueryNodeException { public QueryNode process(QueryNode queryTree) throws QueryNodeException {
Operator op = getQueryConfigHandler().get(ConfigurationKeys.DEFAULT_OPERATOR);
if (!getQueryConfigHandler().hasAttribute(DefaultOperatorAttribute.class)) {
if (op == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"DefaultOperatorAttribute should be set on the QueryConfigHandler"); "StandardQueryConfigHandler.ConfigurationKeys.DEFAULT_OPERATOR should be set on the QueryConfigHandler");
} }
this.usingAnd = Operator.AND == getQueryConfigHandler().getAttribute( this.usingAnd = StandardQueryConfigHandler.Operator.AND == op;
DefaultOperatorAttribute.class).getOperator();
return super.process(queryTree); return super.process(queryTree);

View File

@ -23,25 +23,15 @@ import java.util.TooManyListenersException;
import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.DateTools; import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.DateTools.Resolution;
import org.apache.lucene.queryParser.core.QueryNodeException; import org.apache.lucene.queryParser.core.QueryNodeException;
import org.apache.lucene.queryParser.core.QueryParserHelper; import org.apache.lucene.queryParser.core.QueryParserHelper;
import org.apache.lucene.queryParser.core.config.QueryConfigHandler; import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.builders.StandardQueryTreeBuilder; import org.apache.lucene.queryParser.standard.builders.StandardQueryTreeBuilder;
import org.apache.lucene.queryParser.standard.config.AllowLeadingWildcardAttribute; import org.apache.lucene.queryParser.standard.config.FuzzyConfig;
import org.apache.lucene.queryParser.standard.config.AnalyzerAttribute;
import org.apache.lucene.queryParser.standard.config.DateResolutionAttribute;
import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute;
import org.apache.lucene.queryParser.standard.config.DefaultPhraseSlopAttribute;
import org.apache.lucene.queryParser.standard.config.FieldBoostMapAttribute;
import org.apache.lucene.queryParser.standard.config.FieldDateResolutionMapAttribute;
import org.apache.lucene.queryParser.standard.config.FuzzyAttribute;
import org.apache.lucene.queryParser.standard.config.LocaleAttribute;
import org.apache.lucene.queryParser.standard.config.LowercaseExpandedTermsAttribute;
import org.apache.lucene.queryParser.standard.config.MultiFieldAttribute;
import org.apache.lucene.queryParser.standard.config.MultiTermRewriteMethodAttribute;
import org.apache.lucene.queryParser.standard.config.PositionIncrementsAttribute;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute.Operator; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.Operator;
import org.apache.lucene.queryParser.standard.parser.StandardSyntaxParser; import org.apache.lucene.queryParser.standard.parser.StandardSyntaxParser;
import org.apache.lucene.queryParser.standard.processors.StandardQueryNodeProcessorPipeline; import org.apache.lucene.queryParser.standard.processors.StandardQueryNodeProcessorPipeline;
import org.apache.lucene.search.FuzzyQuery; import org.apache.lucene.search.FuzzyQuery;
@ -179,9 +169,8 @@ public class StandardQueryParser extends QueryParserHelper {
* Gets implicit operator setting, which will be either {@link Operator#AND} * Gets implicit operator setting, which will be either {@link Operator#AND}
* or {@link Operator#OR}. * or {@link Operator#OR}.
*/ */
public Operator getDefaultOperator() { public StandardQueryConfigHandler.Operator getDefaultOperator() {
DefaultOperatorAttribute attr = getQueryConfigHandler().getAttribute(DefaultOperatorAttribute.class); return getQueryConfigHandler().get(ConfigurationKeys.DEFAULT_OPERATOR);
return attr.getOperator();
} }
/** /**
@ -192,9 +181,8 @@ public class StandardQueryParser extends QueryParserHelper {
* In {@link Operator#AND} mode terms are considered to be in conjunction: the * In {@link Operator#AND} mode terms are considered to be in conjunction: the
* above mentioned query is parsed as <code>capital AND of AND Hungary</code> * above mentioned query is parsed as <code>capital AND of AND Hungary</code>
*/ */
public void setDefaultOperator(Operator operator) { public void setDefaultOperator(StandardQueryConfigHandler.Operator operator) {
DefaultOperatorAttribute attr = getQueryConfigHandler().getAttribute(DefaultOperatorAttribute.class); getQueryConfigHandler().set(ConfigurationKeys.DEFAULT_OPERATOR, operator);
attr.setOperator(operator);
} }
/** /**
@ -207,16 +195,22 @@ public class StandardQueryParser extends QueryParserHelper {
* Default: false. * Default: false.
*/ */
public void setLowercaseExpandedTerms(boolean lowercaseExpandedTerms) { public void setLowercaseExpandedTerms(boolean lowercaseExpandedTerms) {
LowercaseExpandedTermsAttribute attr = getQueryConfigHandler().getAttribute(LowercaseExpandedTermsAttribute.class); getQueryConfigHandler().set(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS, lowercaseExpandedTerms);
attr.setLowercaseExpandedTerms(lowercaseExpandedTerms);
} }
/** /**
* @see #setLowercaseExpandedTerms(boolean) * @see #setLowercaseExpandedTerms(boolean)
*/ */
public boolean getLowercaseExpandedTerms() { public boolean getLowercaseExpandedTerms() {
LowercaseExpandedTermsAttribute attr = getQueryConfigHandler().getAttribute(LowercaseExpandedTermsAttribute.class); Boolean lowercaseExpandedTerms = getQueryConfigHandler().get(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS);
return attr.isLowercaseExpandedTerms();
if (lowercaseExpandedTerms == null) {
return true;
} else {
return lowercaseExpandedTerms;
}
} }
/** /**
@ -229,8 +223,7 @@ public class StandardQueryParser extends QueryParserHelper {
* Default: false. * Default: false.
*/ */
public void setAllowLeadingWildcard(boolean allowLeadingWildcard) { public void setAllowLeadingWildcard(boolean allowLeadingWildcard) {
AllowLeadingWildcardAttribute attr = getQueryConfigHandler().getAttribute(AllowLeadingWildcardAttribute.class); getQueryConfigHandler().set(ConfigurationKeys.ALLOW_LEADING_WILDCARD, allowLeadingWildcard);
attr.setAllowLeadingWildcard(allowLeadingWildcard);
} }
/** /**
@ -243,16 +236,22 @@ public class StandardQueryParser extends QueryParserHelper {
* Default: false. * Default: false.
*/ */
public void setEnablePositionIncrements(boolean enabled) { public void setEnablePositionIncrements(boolean enabled) {
PositionIncrementsAttribute attr = getQueryConfigHandler().getAttribute(PositionIncrementsAttribute.class); getQueryConfigHandler().set(ConfigurationKeys.ENABLE_POSITION_INCREMENTS, enabled);
attr.setPositionIncrementsEnabled(enabled);
} }
/** /**
* @see #setEnablePositionIncrements(boolean) * @see #setEnablePositionIncrements(boolean)
*/ */
public boolean getEnablePositionIncrements() { public boolean getEnablePositionIncrements() {
PositionIncrementsAttribute attr = getQueryConfigHandler().getAttribute(PositionIncrementsAttribute.class); Boolean enablePositionsIncrements = getQueryConfigHandler().get(ConfigurationKeys.ENABLE_POSITION_INCREMENTS);
return attr.isPositionIncrementsEnabled();
if (enablePositionsIncrements == null) {
return false;
} else {
return enablePositionsIncrements;
}
} }
/** /**
@ -266,29 +265,42 @@ public class StandardQueryParser extends QueryParserHelper {
* not relevant then use this change the rewrite method. * not relevant then use this change the rewrite method.
*/ */
public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method) { public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method) {
MultiTermRewriteMethodAttribute attr = getQueryConfigHandler().getAttribute(MultiTermRewriteMethodAttribute.class); getQueryConfigHandler().set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, method);
attr.setMultiTermRewriteMethod(method);
} }
/** /**
* @see #setMultiTermRewriteMethod(org.apache.lucene.search.MultiTermQuery.RewriteMethod) * @see #setMultiTermRewriteMethod(org.apache.lucene.search.MultiTermQuery.RewriteMethod)
*/ */
public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod() { public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod() {
MultiTermRewriteMethodAttribute attr = getQueryConfigHandler().getAttribute(MultiTermRewriteMethodAttribute.class); return getQueryConfigHandler().get(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD);
return attr.getMultiTermRewriteMethod();
} }
/**
* Set the fields a query should be expanded to when the field is
* <code>null</code>
*
* @param fields the fields used to expand the query
*/
public void setMultiFields(CharSequence[] fields) { public void setMultiFields(CharSequence[] fields) {
if (fields == null) { if (fields == null) {
fields = new CharSequence[0]; fields = new CharSequence[0];
} }
MultiFieldAttribute attr = getQueryConfigHandler().addAttribute(MultiFieldAttribute.class); getQueryConfigHandler().set(ConfigurationKeys.MULTI_FIELDS, fields);
attr.setFields(fields);
} }
/**
* Returns the fields used to expand the query when the field for a
* certain query is <code>null</code>
*
* @param fields the fields used to expand the query
*/
public void getMultiFields(CharSequence[] fields) {
getQueryConfigHandler().get(ConfigurationKeys.MULTI_FIELDS);
}
/** /**
* Set the prefix length for fuzzy queries. Default is 0. * Set the prefix length for fuzzy queries. Default is 0.
* *
@ -296,65 +308,84 @@ public class StandardQueryParser extends QueryParserHelper {
* The fuzzyPrefixLength to set. * The fuzzyPrefixLength to set.
*/ */
public void setFuzzyPrefixLength(int fuzzyPrefixLength) { public void setFuzzyPrefixLength(int fuzzyPrefixLength) {
FuzzyAttribute attr = getQueryConfigHandler().addAttribute(FuzzyAttribute.class); QueryConfigHandler config = getQueryConfigHandler();
attr.setPrefixLength(fuzzyPrefixLength); FuzzyConfig fuzzyConfig = config.get(ConfigurationKeys.FUZZY_CONFIG);
if (fuzzyConfig == null) {
fuzzyConfig = new FuzzyConfig();
config.set(ConfigurationKeys.FUZZY_CONFIG, fuzzyConfig);
}
fuzzyConfig.setPrefixLength(fuzzyPrefixLength);
} }
/** /**
* Set locale used by date range parsing. * Set locale used by date range parsing.
*/ */
public void setLocale(Locale locale) { public void setLocale(Locale locale) {
LocaleAttribute attr = getQueryConfigHandler().addAttribute(LocaleAttribute.class); getQueryConfigHandler().set(ConfigurationKeys.LOCALE, locale);
attr.setLocale(locale);
} }
/** /**
* Returns current locale, allowing access by subclasses. * Returns current locale, allowing access by subclasses.
*/ */
public Locale getLocale() { public Locale getLocale() {
LocaleAttribute attr = getQueryConfigHandler().addAttribute(LocaleAttribute.class); return getQueryConfigHandler().get(ConfigurationKeys.LOCALE);
return attr.getLocale();
} }
/** /**
* Sets the default slop for phrases. If zero, then exact phrase matches are * Sets the default slop for phrases. If zero, then exact phrase matches are
* required. Default value is zero. * required. Default value is zero.
*
* @deprecated renamed to {@link #setPhraseSlop(int)}
*/ */
@Deprecated
public void setDefaultPhraseSlop(int defaultPhraseSlop) { public void setDefaultPhraseSlop(int defaultPhraseSlop) {
DefaultPhraseSlopAttribute attr = getQueryConfigHandler().addAttribute(DefaultPhraseSlopAttribute.class); getQueryConfigHandler().set(ConfigurationKeys.PHRASE_SLOP, defaultPhraseSlop);
attr.setDefaultPhraseSlop(defaultPhraseSlop); }
/**
* Sets the default slop for phrases. If zero, then exact phrase matches are
* required. Default value is zero.
*/
public void setPhraseSlop(int defaultPhraseSlop) {
getQueryConfigHandler().set(ConfigurationKeys.PHRASE_SLOP, defaultPhraseSlop);
} }
public void setAnalyzer(Analyzer analyzer) { public void setAnalyzer(Analyzer analyzer) {
AnalyzerAttribute attr = getQueryConfigHandler().getAttribute(AnalyzerAttribute.class); getQueryConfigHandler().set(ConfigurationKeys.ANALYZER, analyzer);
attr.setAnalyzer(analyzer);
} }
public Analyzer getAnalyzer() { public Analyzer getAnalyzer() {
QueryConfigHandler config = this.getQueryConfigHandler(); return getQueryConfigHandler().get(ConfigurationKeys.ANALYZER);
if ( config.hasAttribute(AnalyzerAttribute.class)) {
AnalyzerAttribute attr = config.getAttribute(AnalyzerAttribute.class);
return attr.getAnalyzer();
}
return null;
} }
/** /**
* @see #setAllowLeadingWildcard(boolean) * @see #setAllowLeadingWildcard(boolean)
*/ */
public boolean getAllowLeadingWildcard() { public boolean getAllowLeadingWildcard() {
AllowLeadingWildcardAttribute attr = getQueryConfigHandler().addAttribute(AllowLeadingWildcardAttribute.class); Boolean allowLeadingWildcard = getQueryConfigHandler().get(ConfigurationKeys.ALLOW_LEADING_WILDCARD);
return attr.isAllowLeadingWildcard();
if (allowLeadingWildcard == null) {
return false;
} else {
return allowLeadingWildcard;
}
} }
/** /**
* Get the minimal similarity for fuzzy queries. * Get the minimal similarity for fuzzy queries.
*/ */
public float getFuzzyMinSim() { public float getFuzzyMinSim() {
FuzzyAttribute attr = getQueryConfigHandler().addAttribute(FuzzyAttribute.class); FuzzyConfig fuzzyConfig = getQueryConfigHandler().get(ConfigurationKeys.FUZZY_CONFIG);
return attr.getFuzzyMinSimilarity();
if (fuzzyConfig == null) {
return FuzzyQuery.defaultMinSimilarity;
} else {
return fuzzyConfig.getMinSimilarity();
}
} }
/** /**
@ -363,16 +394,27 @@ public class StandardQueryParser extends QueryParserHelper {
* @return Returns the fuzzyPrefixLength. * @return Returns the fuzzyPrefixLength.
*/ */
public int getFuzzyPrefixLength() { public int getFuzzyPrefixLength() {
FuzzyAttribute attr = getQueryConfigHandler().addAttribute(FuzzyAttribute.class); FuzzyConfig fuzzyConfig = getQueryConfigHandler().get(ConfigurationKeys.FUZZY_CONFIG);
return attr.getPrefixLength();
if (fuzzyConfig == null) {
return FuzzyQuery.defaultPrefixLength;
} else {
return fuzzyConfig.getPrefixLength();
}
} }
/** /**
* Gets the default slop for phrases. * Gets the default slop for phrases.
*/ */
public int getPhraseSlop() { public int getPhraseSlop() {
DefaultPhraseSlopAttribute attr = getQueryConfigHandler().addAttribute(DefaultPhraseSlopAttribute.class); Integer phraseSlop = getQueryConfigHandler().get(ConfigurationKeys.PHRASE_SLOP);
return attr.getDefaultPhraseSlop();
if (phraseSlop == null) {
return 0;
} else {
return phraseSlop;
}
} }
/** /**
@ -380,23 +422,83 @@ public class StandardQueryParser extends QueryParserHelper {
* {@link FuzzyQuery#defaultMinSimilarity}. * {@link FuzzyQuery#defaultMinSimilarity}.
*/ */
public void setFuzzyMinSim(float fuzzyMinSim) { public void setFuzzyMinSim(float fuzzyMinSim) {
FuzzyAttribute attr = getQueryConfigHandler().addAttribute(FuzzyAttribute.class); QueryConfigHandler config = getQueryConfigHandler();
attr.setFuzzyMinSimilarity(fuzzyMinSim); FuzzyConfig fuzzyConfig = config.get(ConfigurationKeys.FUZZY_CONFIG);
if (fuzzyConfig == null) {
fuzzyConfig = new FuzzyConfig();
config.set(ConfigurationKeys.FUZZY_CONFIG, fuzzyConfig);
}
fuzzyConfig.setMinSimilarity(fuzzyMinSim);
} }
/**
* Sets the boost used for each field.
*
* @param boosts a collection that maps a field to its boost
*/
public void setFieldsBoost(Map<String, Float> boosts) { public void setFieldsBoost(Map<String, Float> boosts) {
FieldBoostMapAttribute attr = getQueryConfigHandler().addAttribute(FieldBoostMapAttribute.class); getQueryConfigHandler().set(ConfigurationKeys.FIELD_BOOST_MAP, boosts);
attr.setFieldBoostMap(boosts); }
/**
* Returns the field to boost map used to set boost for each field.
*
* @return the field to boost map
*/
public Map<String, Float> getFieldsBoost() {
return getQueryConfigHandler().get(ConfigurationKeys.FIELD_BOOST_MAP);
} }
/**
* Sets the default {@link Resolution} used for certain field when
* no {@link Resolution} is defined for this field.
*
* @param dateResolution the default {@link Resolution}
*/
public void setDateResolution(DateTools.Resolution dateResolution) { public void setDateResolution(DateTools.Resolution dateResolution) {
DateResolutionAttribute attr = getQueryConfigHandler().addAttribute(DateResolutionAttribute.class); getQueryConfigHandler().set(ConfigurationKeys.DATE_RESOLUTION, dateResolution);
attr.setDateResolution(dateResolution); }
/**
* Returns the default {@link Resolution} used for certain field when
* no {@link Resolution} is defined for this field.
*
* @return the default {@link Resolution}
*/
public DateTools.Resolution getDateResolution() {
return getQueryConfigHandler().get(ConfigurationKeys.DATE_RESOLUTION);
} }
/**
* Sets the {@link Resolution} used for each field
*
* @param dateRes a collection that maps a field to its {@link Resolution}
*
* @deprecated this method was renamed to {@link #setDateResolutionMap(Map)}
*/
@Deprecated
public void setDateResolution(Map<CharSequence, DateTools.Resolution> dateRes) { public void setDateResolution(Map<CharSequence, DateTools.Resolution> dateRes) {
FieldDateResolutionMapAttribute attr = getQueryConfigHandler().addAttribute(FieldDateResolutionMapAttribute.class); setDateResolutionMap(dateRes);
attr.setFieldDateResolutionMap(dateRes); }
/**
* Returns the field to {@link Resolution} map used to normalize each date field.
*
* @return the field to {@link Resolution} map
*/
public Map<CharSequence, DateTools.Resolution> getDateResolutionMap() {
return getQueryConfigHandler().get(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP);
}
/**
* Sets the {@link Resolution} used for each field
*
* @param dateRes a collection that maps a field to its {@link Resolution}
*/
public void setDateResolutionMap(Map<CharSequence, DateTools.Resolution> dateRes) {
getQueryConfigHandler().set(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP, dateRes);
} }
} }

View File

@ -20,8 +20,8 @@ package org.apache.lucene.queryParser.standard.builders;
import org.apache.lucene.index.Term; import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.core.QueryNodeException; import org.apache.lucene.queryParser.core.QueryNodeException;
import org.apache.lucene.queryParser.core.nodes.QueryNode; import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.standard.config.MultiTermRewriteMethodAttribute;
import org.apache.lucene.queryParser.standard.nodes.PrefixWildcardQueryNode; import org.apache.lucene.queryParser.standard.nodes.PrefixWildcardQueryNode;
import org.apache.lucene.queryParser.standard.processors.MultiTermRewriteMethodProcessor;
import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.PrefixQuery; import org.apache.lucene.search.PrefixQuery;
@ -42,7 +42,7 @@ public class PrefixWildcardQueryNodeBuilder implements StandardQueryBuilder {
String text = wildcardNode.getText().subSequence(0, wildcardNode.getText().length() - 1).toString(); String text = wildcardNode.getText().subSequence(0, wildcardNode.getText().length() - 1).toString();
PrefixQuery q = new PrefixQuery(new Term(wildcardNode.getFieldAsString(), text)); PrefixQuery q = new PrefixQuery(new Term(wildcardNode.getFieldAsString(), text));
MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodAttribute.TAG_ID); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodProcessor.TAG_ID);
if (method != null) { if (method != null) {
q.setRewriteMethod(method); q.setRewriteMethod(method);
} }

View File

@ -21,8 +21,8 @@ import org.apache.lucene.queryParser.core.QueryNodeException;
import org.apache.lucene.queryParser.core.nodes.ParametricQueryNode; import org.apache.lucene.queryParser.core.nodes.ParametricQueryNode;
import org.apache.lucene.queryParser.core.nodes.QueryNode; import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.core.nodes.ParametricQueryNode.CompareOperator; import org.apache.lucene.queryParser.core.nodes.ParametricQueryNode.CompareOperator;
import org.apache.lucene.queryParser.standard.config.MultiTermRewriteMethodAttribute;
import org.apache.lucene.queryParser.standard.nodes.RangeQueryNode; import org.apache.lucene.queryParser.standard.nodes.RangeQueryNode;
import org.apache.lucene.queryParser.standard.processors.MultiTermRewriteMethodProcessor;
import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.TermRangeQuery; import org.apache.lucene.search.TermRangeQuery;
@ -55,7 +55,7 @@ public class RangeQueryNodeBuilder implements StandardQueryBuilder {
TermRangeQuery rangeQuery = TermRangeQuery.newStringRange(field, lower.getTextAsString(), upper.getTextAsString(), lowerInclusive, upperInclusive); TermRangeQuery rangeQuery = TermRangeQuery.newStringRange(field, lower.getTextAsString(), upper.getTextAsString(), lowerInclusive, upperInclusive);
MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodAttribute.TAG_ID); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodProcessor.TAG_ID);
if (method != null) { if (method != null) {
rangeQuery.setRewriteMethod(method); rangeQuery.setRewriteMethod(method);
} }

View File

@ -20,8 +20,8 @@ package org.apache.lucene.queryParser.standard.builders;
import org.apache.lucene.index.Term; import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.core.QueryNodeException; import org.apache.lucene.queryParser.core.QueryNodeException;
import org.apache.lucene.queryParser.core.nodes.QueryNode; import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.standard.config.MultiTermRewriteMethodAttribute;
import org.apache.lucene.queryParser.standard.nodes.RegexpQueryNode; import org.apache.lucene.queryParser.standard.nodes.RegexpQueryNode;
import org.apache.lucene.queryParser.standard.processors.MultiTermRewriteMethodProcessor;
import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.RegexpQuery; import org.apache.lucene.search.RegexpQuery;
@ -41,7 +41,7 @@ public class RegexpQueryNodeBuilder implements StandardQueryBuilder {
regexpNode.textToBytesRef())); regexpNode.textToBytesRef()));
MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod) queryNode MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod) queryNode
.getTag(MultiTermRewriteMethodAttribute.TAG_ID); .getTag(MultiTermRewriteMethodProcessor.TAG_ID);
if (method != null) { if (method != null) {
q.setRewriteMethod(method); q.setRewriteMethod(method);
} }

View File

@ -20,8 +20,8 @@ package org.apache.lucene.queryParser.standard.builders;
import org.apache.lucene.index.Term; import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.core.QueryNodeException; import org.apache.lucene.queryParser.core.QueryNodeException;
import org.apache.lucene.queryParser.core.nodes.QueryNode; import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.standard.config.MultiTermRewriteMethodAttribute;
import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode; import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode;
import org.apache.lucene.queryParser.standard.processors.MultiTermRewriteMethodProcessor;
import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.WildcardQuery; import org.apache.lucene.search.WildcardQuery;
@ -41,7 +41,7 @@ public class WildcardQueryNodeBuilder implements StandardQueryBuilder {
WildcardQuery q = new WildcardQuery(new Term(wildcardNode.getFieldAsString(), WildcardQuery q = new WildcardQuery(new Term(wildcardNode.getFieldAsString(),
wildcardNode.getTextAsString())); wildcardNode.getTextAsString()));
MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodAttribute.TAG_ID); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodProcessor.TAG_ID);
if (method != null) { if (method != null) {
q.setRewriteMethod(method); q.setRewriteMethod(method);
} }

View File

@ -1,79 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.AllowLeadingWildcardProcessor;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by {@link AllowLeadingWildcardProcessor} processor and
* must be defined in the {@link QueryConfigHandler}. It basically tells the
* processor if it should allow leading wildcard. <br/>
*
* @see org.apache.lucene.queryParser.standard.config.AllowLeadingWildcardAttribute
*/
public class AllowLeadingWildcardAttributeImpl extends AttributeImpl
implements AllowLeadingWildcardAttribute {
private boolean allowLeadingWildcard = false; // default in 2.9
public void setAllowLeadingWildcard(boolean allowLeadingWildcard) {
this.allowLeadingWildcard = allowLeadingWildcard;
}
public boolean isAllowLeadingWildcard() {
return this.allowLeadingWildcard;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof AllowLeadingWildcardAttributeImpl
&& ((AllowLeadingWildcardAttributeImpl) other).allowLeadingWildcard == this.allowLeadingWildcard) {
return true;
}
return false;
}
@Override
public int hashCode() {
return this.allowLeadingWildcard ? -1 : Integer.MAX_VALUE;
}
@Override
public String toString() {
return "<allowLeadingWildcard allowLeadingWildcard="
+ this.allowLeadingWildcard + "/>";
}
}

View File

@ -1,35 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.AnalyzerQueryNodeProcessor;
import org.apache.lucene.util.Attribute;
/**
* This attribute is used by {@link AnalyzerQueryNodeProcessor} processor and
* must be defined in the {@link QueryConfigHandler}. It provides to this
* processor the {@link Analyzer}, if there is one, which will be used to
* analyze the query terms. <br/>
*
*/
public interface AnalyzerAttribute extends Attribute {
public void setAnalyzer(Analyzer analyzer);
public Analyzer getAnalyzer();
}

View File

@ -1,90 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.AnalyzerQueryNodeProcessor;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by {@link AnalyzerQueryNodeProcessor} processor and
* must be defined in the {@link QueryConfigHandler}. It provides to this
* processor the {@link Analyzer}, if there is one, which will be used to
* analyze the query terms. <br/>
*
* @see org.apache.lucene.queryParser.standard.config.AnalyzerAttribute
*/
public class AnalyzerAttributeImpl extends AttributeImpl
implements AnalyzerAttribute {
private Analyzer analyzer;
public AnalyzerAttributeImpl() {
analyzer = null; //default value 2.4
}
public void setAnalyzer(Analyzer analyzer) {
this.analyzer = analyzer;
}
public Analyzer getAnalyzer() {
return this.analyzer;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof AnalyzerAttributeImpl) {
AnalyzerAttributeImpl analyzerAttr = (AnalyzerAttributeImpl) other;
if (analyzerAttr.analyzer == this.analyzer
|| (this.analyzer != null && analyzerAttr.analyzer != null && this.analyzer
.equals(analyzerAttr.analyzer))) {
return true;
}
}
return false;
}
@Override
public int hashCode() {
return (this.analyzer == null) ? 0 : this.analyzer.hashCode();
}
@Override
public String toString() {
return "<analyzerAttribute analyzer='" + this.analyzer + "'/>";
}
}

View File

@ -1,84 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.queryParser.core.config.FieldConfig;
import org.apache.lucene.queryParser.standard.processors.MultiFieldQueryNodeProcessor;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by {@link MultiFieldQueryNodeProcessor} processor and
* it should be defined in a {@link FieldConfig}. This processor uses this
* attribute to define which boost a specific field should have when none is
* defined to it. <br/>
* <br/>
*
* @see org.apache.lucene.queryParser.standard.config.BoostAttribute
*/
public class BoostAttributeImpl extends AttributeImpl
implements BoostAttribute {
private float boost = 1.0f;
public BoostAttributeImpl() {
// empty constructor
}
public void setBoost(float boost) {
this.boost = boost;
}
public float getBoost() {
return this.boost;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof BoostAttributeImpl
&& ((BoostAttributeImpl) other).boost == this.boost) {
return true;
}
return false;
}
@Override
public int hashCode() {
return Float.valueOf(this.boost).hashCode();
}
@Override
public String toString() {
return "<boostAttribute boost=" + this.boost + "/>";
}
}

View File

@ -1,43 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.DateTools.Resolution;
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.nodes.RangeQueryNode;
import org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor;
import org.apache.lucene.util.Attribute;
/**
* This attribute is used by {@link ParametricRangeQueryNodeProcessor} processor
* and must be defined in the {@link QueryConfigHandler}. This attribute tells
* the processor which {@link Resolution} to use when parsing the date. <br/>
*
*/
public interface DateResolutionAttribute extends Attribute {
/**
* Sets the default date resolution used by {@link RangeQueryNode}s for
* fields for which no specific date resolutions has been set. Field
* specific resolutions can be set with
*
* @param dateResolution the default date resolution to set
*/
public void setDateResolution(DateTools.Resolution dateResolution);
public DateTools.Resolution getDateResolution();
}

View File

@ -1,90 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.DateTools.Resolution;
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by {@link ParametricRangeQueryNodeProcessor} processor
* and must be defined in the {@link QueryConfigHandler}. This attribute tells
* the processor which {@link Resolution} to use when parsing the date. <br/>
*
* @see org.apache.lucene.queryParser.standard.config.DateResolutionAttribute
*/
public class DateResolutionAttributeImpl extends AttributeImpl
implements DateResolutionAttribute {
private DateTools.Resolution dateResolution = null;
public DateResolutionAttributeImpl() {
dateResolution = null; //default in 2.4
}
public void setDateResolution(DateTools.Resolution dateResolution) {
this.dateResolution = dateResolution;
}
public DateTools.Resolution getDateResolution() {
return this.dateResolution;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof DateResolutionAttributeImpl) {
DateResolutionAttributeImpl dateResAttr = (DateResolutionAttributeImpl) other;
if (dateResAttr.getDateResolution() == getDateResolution()
|| dateResAttr.getDateResolution().equals(getDateResolution())) {
return true;
}
}
return false;
}
@Override
public int hashCode() {
return (this.dateResolution == null) ? 0 : this.dateResolution.hashCode();
}
@Override
public String toString() {
return "<dateResolutionAttribute dateResolution='" + this.dateResolution
+ "'/>";
}
}

View File

@ -1,92 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.GroupQueryNodeProcessor;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by {@link GroupQueryNodeProcessor} processor and must
* be defined in the {@link QueryConfigHandler}. This attribute tells the
* processor which is the default boolean operator when no operator is defined
* between terms. <br/>
*
* @see org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute
*/
public class DefaultOperatorAttributeImpl extends AttributeImpl
implements DefaultOperatorAttribute {
private Operator operator = Operator.OR;
public DefaultOperatorAttributeImpl() {
// empty constructor
}
public void setOperator(Operator operator) {
if (operator == null) {
throw new IllegalArgumentException("default operator cannot be null!");
}
this.operator = operator;
}
public Operator getOperator() {
return this.operator;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof DefaultOperatorAttributeImpl) {
DefaultOperatorAttributeImpl defaultOperatorAttr = (DefaultOperatorAttributeImpl) other;
if (defaultOperatorAttr.getOperator() == this.getOperator()) {
return true;
}
}
return false;
}
@Override
public int hashCode() {
return getOperator().hashCode() * 31;
}
@Override
public String toString() {
return "<defaultOperatorAttribute operator=" + this.operator.name() + "/>";
}
}

View File

@ -1,84 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.PhraseSlopQueryNodeProcessor;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by {@link PhraseSlopQueryNodeProcessor} processor and
* must be defined in the {@link QueryConfigHandler}. This attribute tells the
* processor what is the default phrase slop when no slop is defined in a
* phrase. <br/>
*
* @see org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute
*/
public class DefaultPhraseSlopAttributeImpl extends AttributeImpl
implements DefaultPhraseSlopAttribute {
private int defaultPhraseSlop = 0;
public DefaultPhraseSlopAttributeImpl() {
defaultPhraseSlop = 0; //default value in 2.4
}
public void setDefaultPhraseSlop(int defaultPhraseSlop) {
this.defaultPhraseSlop = defaultPhraseSlop;
}
public int getDefaultPhraseSlop() {
return this.defaultPhraseSlop;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof DefaultPhraseSlopAttributeImpl
&& ((DefaultPhraseSlopAttributeImpl) other).defaultPhraseSlop == this.defaultPhraseSlop) {
return true;
}
return false;
}
@Override
public int hashCode() {
return Integer.valueOf(this.defaultPhraseSlop).hashCode();
}
@Override
public String toString() {
return "<defaultPhraseSlop defaultPhraseSlop=" + this.defaultPhraseSlop
+ "/>";
}
}

View File

@ -1,92 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.lucene.queryParser.core.config.FieldConfig;
import org.apache.lucene.queryParser.standard.processors.MultiFieldQueryNodeProcessor;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by {@link MultiFieldQueryNodeProcessor} processor and
* it should be defined in a {@link FieldConfig}. This processor uses this
* attribute to define which boost a specific field should have when none is
* defined to it. <br/>
* <br/>
*
* @see org.apache.lucene.queryParser.standard.config.BoostAttribute
*/
public class FieldBoostMapAttributeImpl extends AttributeImpl
implements FieldBoostMapAttribute {
private Map<String, Float> boosts = new LinkedHashMap<String, Float>();
public FieldBoostMapAttributeImpl() {
// empty constructor
}
public void setFieldBoostMap(Map<String, Float> boosts) {
this.boosts = boosts;
}
public Map<String, Float> getFieldBoostMap() {
return this.boosts;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof FieldBoostMapAttributeImpl
&& ((FieldBoostMapAttributeImpl) other).boosts.equals(this.boosts) ) {
return true;
}
return false;
}
@Override
public int hashCode() {
final int prime = 97;
if (this.boosts != null)
return this.boosts.hashCode() * prime;
else
return Float.valueOf(prime).hashCode();
}
@Override
public String toString() {
return "<fieldBoostMapAttribute map=" + this.boosts + "/>";
}
}

View File

@ -17,18 +17,21 @@ package org.apache.lucene.queryParser.standard.config;
* limitations under the License. * limitations under the License.
*/ */
import java.util.Map;
import org.apache.lucene.queryParser.core.config.FieldConfig; import org.apache.lucene.queryParser.core.config.FieldConfig;
import org.apache.lucene.queryParser.core.config.FieldConfigListener; import org.apache.lucene.queryParser.core.config.FieldConfigListener;
import org.apache.lucene.queryParser.core.config.QueryConfigHandler; import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
/** /**
* This listener listens for every field configuration request and assign a * This listener listens for every field configuration request and assign a
* {@link BoostAttribute} to the equivalent {@link FieldConfig} based on a * {@link ConfigurationKeys#BOOST} to the
* defined map: fieldName -> boostValue store in {@link FieldBoostMapAttribute} * equivalent {@link FieldConfig} based on a defined map: fieldName -> boostValue stored in
* in the {@link FieldBoostMapAttribute}. * {@link ConfigurationKeys#FIELD_BOOST_MAP}.
* *
* @see BoostAttribute * @see ConfigurationKeys#FIELD_BOOST_MAP
* @see FieldBoostMapAttribute * @see ConfigurationKeys#BOOST
* @see FieldConfig * @see FieldConfig
* @see FieldConfigListener * @see FieldConfigListener
*/ */
@ -40,15 +43,14 @@ public class FieldBoostMapFCListener implements FieldConfigListener {
this.config = config; this.config = config;
} }
public void buildFieldConfig(FieldConfig fieldConfig) { public void buildFieldConfig(FieldConfig fieldConfig) {
if (this.config.hasAttribute(FieldBoostMapAttribute.class)) { Map<String, Float> fieldBoostMap = this.config.get(ConfigurationKeys.FIELD_BOOST_MAP);
FieldBoostMapAttribute fieldBoostMapAttr = this.config.getAttribute(FieldBoostMapAttribute.class);
BoostAttribute boostAttr = fieldConfig.addAttribute(BoostAttribute.class); if (fieldBoostMap != null) {
Float boost = fieldBoostMap.get(fieldConfig.getField());
Float boost = fieldBoostMapAttr.getFieldBoostMap().get(fieldConfig.getField());
if (boost != null) { if (boost != null) {
boostAttr.setBoost(boost.floatValue()); fieldConfig.set(ConfigurationKeys.BOOST, boost);
} }
} }

View File

@ -17,20 +17,23 @@ package org.apache.lucene.queryParser.standard.config;
* limitations under the License. * limitations under the License.
*/ */
import java.util.Map;
import org.apache.lucene.document.DateTools; import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.DateTools.Resolution;
import org.apache.lucene.queryParser.core.config.FieldConfig; import org.apache.lucene.queryParser.core.config.FieldConfig;
import org.apache.lucene.queryParser.core.config.FieldConfigListener; import org.apache.lucene.queryParser.core.config.FieldConfigListener;
import org.apache.lucene.queryParser.core.config.QueryConfigHandler; import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
/** /**
* This listener listens for every field configuration request and assign a * This listener listens for every field configuration request and assign a
* {@link DateResolutionAttribute} to the equivalent {@link FieldConfig} based * {@link ConfigurationKeys#DATE_RESOLUTION} to the equivalent {@link FieldConfig} based
* on a defined map: fieldName -> DateTools.Resolution stored in * on a defined map: fieldName -> {@link Resolution} stored in
* {@link FieldDateResolutionMapAttribute} in the * {@link ConfigurationKeys#FIELD_DATE_RESOLUTION_MAP}.
* {@link DateResolutionAttribute}.
* *
* @see DateResolutionAttribute * @see ConfigurationKeys#DATE_RESOLUTION
* @see FieldDateResolutionMapAttribute * @see ConfigurationKeys#FIELD_DATE_RESOLUTION_MAP
* @see FieldConfig * @see FieldConfig
* @see FieldConfigListener * @see FieldConfigListener
*/ */
@ -43,29 +46,21 @@ public class FieldDateResolutionFCListener implements FieldConfigListener {
} }
public void buildFieldConfig(FieldConfig fieldConfig) { public void buildFieldConfig(FieldConfig fieldConfig) {
DateResolutionAttribute fieldDateResAttr = fieldConfig
.addAttribute(DateResolutionAttribute.class);
DateTools.Resolution dateRes = null; DateTools.Resolution dateRes = null;
Map<CharSequence, DateTools.Resolution> dateResMap = this.config.get(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP);
if (this.config.hasAttribute(FieldDateResolutionMapAttribute.class)) { if (dateResMap != null) {
FieldDateResolutionMapAttribute dateResMapAttr = this.config dateRes = dateResMap.get(
.addAttribute(FieldDateResolutionMapAttribute.class);
dateRes = dateResMapAttr.getFieldDateResolutionMap().get(
fieldConfig.getField()); fieldConfig.getField());
} }
if (dateRes == null) { if (dateRes == null) {
dateRes = this.config.get(ConfigurationKeys.DATE_RESOLUTION);
if (this.config.hasAttribute(DateResolutionAttribute.class)) {
DateResolutionAttribute dateResAttr = this.config
.addAttribute(DateResolutionAttribute.class);
dateRes = dateResAttr.getDateResolution();
}
} }
fieldDateResAttr.setDateResolution(dateRes); if (dateRes != null) {
fieldConfig.set(ConfigurationKeys.DATE_RESOLUTION, dateRes);
}
} }

View File

@ -1,89 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.HashMap;
import java.util.Map;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.DateTools.Resolution;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute enables the user to define a default DateResolution per field.
* it's used by {@link FieldDateResolutionFCListener#buildFieldConfig(org.apache.lucene.queryParser.core.config.FieldConfig)}
*
* @see FieldDateResolutionMapAttribute
*/
public class FieldDateResolutionMapAttributeImpl extends AttributeImpl
implements FieldDateResolutionMapAttribute {
private Map<CharSequence, DateTools.Resolution> dateRes = new HashMap<CharSequence, DateTools.Resolution>();
public FieldDateResolutionMapAttributeImpl() {
// empty constructor
}
public void setFieldDateResolutionMap(Map<CharSequence, DateTools.Resolution> dateRes) {
this.dateRes = dateRes;
}
public Map<CharSequence, Resolution> getFieldDateResolutionMap() {
return this.dateRes;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof FieldDateResolutionMapAttributeImpl
&& ((FieldDateResolutionMapAttributeImpl) other).dateRes.equals(this.dateRes) ) {
return true;
}
return false;
}
@Override
public int hashCode() {
final int prime = 97;
if (this.dateRes != null)
return this.dateRes.hashCode() * prime;
else
return Float.valueOf(prime).hashCode();
}
@Override
public String toString() {
return "<fieldDateResolutionMapAttribute map=" + this.dateRes + "/>";
}
}

View File

@ -1,36 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.PhraseSlopQueryNodeProcessor;
import org.apache.lucene.util.Attribute;
/**
* This attribute is used by {@link PhraseSlopQueryNodeProcessor} processor and
* must be defined in the {@link QueryConfigHandler}. This attribute tells the
* processor what is the default phrase slop when no slop is defined in a
* phrase. <br/>
*
*/
public interface FuzzyAttribute extends Attribute {
public void setPrefixLength(int prefixLength);
public int getPrefixLength();
public void setFuzzyMinSimilarity(float minSimilarity);
public float getFuzzyMinSimilarity();
}

View File

@ -1,94 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.PhraseSlopQueryNodeProcessor;
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by {@link PhraseSlopQueryNodeProcessor} processor and
* must be defined in the {@link QueryConfigHandler}. This attribute tells the
* processor what is the default phrase slop when no slop is defined in a
* phrase. <br/>
*
* @see org.apache.lucene.queryParser.standard.config.FuzzyAttribute
*/
public class FuzzyAttributeImpl extends AttributeImpl
implements FuzzyAttribute {
private int prefixLength = FuzzyQuery.defaultPrefixLength;
private float minSimilarity = FuzzyQuery.defaultMinSimilarity;
public FuzzyAttributeImpl() {
// empty constructor
}
public void setPrefixLength(int prefixLength) {
this.prefixLength = prefixLength;
}
public int getPrefixLength() {
return this.prefixLength;
}
public void setFuzzyMinSimilarity(float minSimilarity) {
this.minSimilarity = minSimilarity;
}
public float getFuzzyMinSimilarity() {
return this.minSimilarity;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof FuzzyAttributeImpl
&& ((FuzzyAttributeImpl) other).prefixLength == this.prefixLength) {
return true;
}
return false;
}
@Override
public int hashCode() {
return Integer.valueOf(this.prefixLength).hashCode();
}
@Override
public String toString() {
return "<fuzzyAttribute prefixLength=" + this.prefixLength + "/>";
}
}

View File

@ -17,19 +17,30 @@ package org.apache.lucene.queryParser.standard.config;
* limitations under the License. * limitations under the License.
*/ */
import java.util.Map; import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.queryParser.core.config.FieldConfig; public class FuzzyConfig {
import org.apache.lucene.util.Attribute;
private int prefixLength = FuzzyQuery.defaultPrefixLength;
/** private float minSimilarity = FuzzyQuery.defaultMinSimilarity;
* This attribute enables the user to define a default boost per field.
* it's used by {@link FieldBoostMapFCListener#buildFieldConfig(FieldConfig)} public FuzzyConfig() {}
*/
public interface FieldBoostMapAttribute extends Attribute { public int getPrefixLength() {
/** return prefixLength;
* @param boosts a mapping from field name to its default boost }
*/
public void setFieldBoostMap(Map<String, Float> boosts); public void setPrefixLength(int prefixLength) {
public Map<String, Float> getFieldBoostMap(); this.prefixLength = prefixLength;
}
public float getMinSimilarity() {
return minSimilarity;
}
public void setMinSimilarity(float minSimilarity) {
this.minSimilarity = minSimilarity;
}
} }

View File

@ -1,90 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.Locale;
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by processor {@link ParametricRangeQueryNodeProcessor}
* and must be defined in the {@link QueryConfigHandler}. This attribute tells
* the processor what is the default {@link Locale} used to parse a date. <br/>
*
* @see org.apache.lucene.queryParser.standard.config.LocaleAttribute
*/
public class LocaleAttributeImpl extends AttributeImpl
implements LocaleAttribute {
private Locale locale = Locale.getDefault();
public LocaleAttributeImpl() {
locale = Locale.getDefault(); //default in 2.4
}
public void setLocale(Locale locale) {
this.locale = locale;
}
public Locale getLocale() {
return this.locale;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof LocaleAttributeImpl) {
LocaleAttributeImpl localeAttr = (LocaleAttributeImpl) other;
if (localeAttr.locale == this.locale
|| (this.locale != null && localeAttr.locale != null && this.locale
.equals(localeAttr.locale))) {
return true;
}
}
return false;
}
@Override
public int hashCode() {
return (this.locale == null) ? 0 : this.locale.hashCode();
}
@Override
public String toString() {
return "<localeAttribute locale=" + this.locale + "/>";
}
}

View File

@ -1,85 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.Locale;
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by processor {@link ParametricRangeQueryNodeProcessor}
* and must be defined in the {@link QueryConfigHandler}. This attribute tells
* the processor what is the default {@link Locale} used to parse a date. <br/>
*
* @see org.apache.lucene.queryParser.standard.config.LowercaseExpandedTermsAttribute
*/
public class LowercaseExpandedTermsAttributeImpl extends AttributeImpl
implements LowercaseExpandedTermsAttribute {
private boolean lowercaseExpandedTerms = true;
public LowercaseExpandedTermsAttributeImpl() {
lowercaseExpandedTerms = true; // default in 2.4
}
public void setLowercaseExpandedTerms(boolean lowercaseExpandedTerms) {
this.lowercaseExpandedTerms = lowercaseExpandedTerms;
}
public boolean isLowercaseExpandedTerms() {
return this.lowercaseExpandedTerms;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof LowercaseExpandedTermsAttributeImpl
&& ((LowercaseExpandedTermsAttributeImpl) other).lowercaseExpandedTerms == this.lowercaseExpandedTerms) {
return true;
}
return false;
}
@Override
public int hashCode() {
return this.lowercaseExpandedTerms ? -1 : Integer.MAX_VALUE;
}
@Override
public String toString() {
return "<lowercaseExpandedTerms lowercaseExpandedTerms="
+ this.lowercaseExpandedTerms + "/>";
}
}

View File

@ -1,84 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.Arrays;
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.MultiFieldQueryNodeProcessor;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by {@link MultiFieldQueryNodeProcessor} processor and
* must be defined in the {@link QueryConfigHandler}. This attribute tells the
* processor to which fields the terms in the query should be expanded. <br/>
*
* @see org.apache.lucene.queryParser.standard.config.MultiFieldAttribute
*/
public class MultiFieldAttributeImpl extends AttributeImpl
implements MultiFieldAttribute {
private CharSequence[] fields;
public MultiFieldAttributeImpl() {
// empty constructor
}
public void setFields(CharSequence[] fields) {
this.fields = fields;
}
public CharSequence[] getFields() {
return this.fields;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof MultiFieldAttributeImpl) {
MultiFieldAttributeImpl fieldsAttr = (MultiFieldAttributeImpl) other;
return Arrays.equals(this.fields, fieldsAttr.fields);
}
return false;
}
@Override
public int hashCode() {
return Arrays.hashCode(this.fields);
}
@Override
public String toString() {
return "<fieldsAttribute fields=" + Arrays.toString(this.fields) + "/>";
}
}

View File

@ -1,40 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor;
import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.MultiTermQuery.RewriteMethod;
import org.apache.lucene.util.Attribute;
/**
* This attribute is used by {@link ParametricRangeQueryNodeProcessor} processor
* and should be defined in the {@link QueryConfigHandler} used by this
* processor. It basically tells the processor which {@link RewriteMethod} to
* use. <br/>
*
*/
public interface MultiTermRewriteMethodAttribute extends Attribute {
public static final String TAG_ID = "MultiTermRewriteMethodAttribute";
public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method);
public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod();
}

View File

@ -1,86 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor;
import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.MultiTermQuery.RewriteMethod;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by {@link ParametricRangeQueryNodeProcessor} processor
* and should be defined in the {@link QueryConfigHandler} used by this
* processor. It basically tells the processor which {@link RewriteMethod} to
* use. <br/>
*
* @see MultiTermRewriteMethodAttribute
*/
public class MultiTermRewriteMethodAttributeImpl extends AttributeImpl
implements MultiTermRewriteMethodAttribute {
private MultiTermQuery.RewriteMethod multiTermRewriteMethod = MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT;
public MultiTermRewriteMethodAttributeImpl() {
// empty constructor
}
public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method) {
multiTermRewriteMethod = method;
}
public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod() {
return multiTermRewriteMethod;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof MultiTermRewriteMethodAttributeImpl
&& ((MultiTermRewriteMethodAttributeImpl) other).multiTermRewriteMethod == this.multiTermRewriteMethod) {
return true;
}
return false;
}
@Override
public int hashCode() {
return multiTermRewriteMethod.hashCode();
}
@Override
public String toString() {
return "<multiTermRewriteMethod multiTermRewriteMethod="
+ this.multiTermRewriteMethod + "/>";
}
}

View File

@ -1,33 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.AnalyzerQueryNodeProcessor;
import org.apache.lucene.util.Attribute;
/**
* This attribute is used by {@link AnalyzerQueryNodeProcessor} processor and
* must be defined in the {@link QueryConfigHandler}. This attribute tells the
* processor if the position increment is enabled. <br/>
*
*/
public interface PositionIncrementsAttribute extends Attribute {
public void setPositionIncrementsEnabled(boolean positionIncrementsEnabled);
public boolean isPositionIncrementsEnabled();
}

View File

@ -1,83 +0,0 @@
package org.apache.lucene.queryParser.standard.config;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.processors.AnalyzerQueryNodeProcessor;
import org.apache.lucene.util.AttributeImpl;
/**
* This attribute is used by {@link AnalyzerQueryNodeProcessor} processor and
* must be defined in the {@link QueryConfigHandler}. This attribute tells the
* processor if the position increment is enabled. <br/>
*
* @see org.apache.lucene.queryParser.standard.config.PositionIncrementsAttribute
*/
public class PositionIncrementsAttributeImpl extends AttributeImpl
implements PositionIncrementsAttribute {
private boolean positionIncrementsEnabled = false;
public PositionIncrementsAttributeImpl() {
positionIncrementsEnabled = false; //default in 2.4
}
public void setPositionIncrementsEnabled(boolean positionIncrementsEnabled) {
this.positionIncrementsEnabled = positionIncrementsEnabled;
}
public boolean isPositionIncrementsEnabled() {
return this.positionIncrementsEnabled;
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public void copyTo(AttributeImpl target) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object other) {
if (other instanceof PositionIncrementsAttributeImpl
&& ((PositionIncrementsAttributeImpl) other).positionIncrementsEnabled == this.positionIncrementsEnabled) {
return true;
}
return false;
}
@Override
public int hashCode() {
return this.positionIncrementsEnabled ? -1 : Integer.MAX_VALUE;
}
@Override
public String toString() {
return "<positionIncrements positionIncrementsEnabled="
+ this.positionIncrementsEnabled + "/>";
}
}

View File

@ -17,37 +17,173 @@ package org.apache.lucene.queryParser.standard.config;
* limitations under the License. * limitations under the License.
*/ */
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.DateTools.Resolution;
import org.apache.lucene.queryParser.core.config.ConfigurationKey;
import org.apache.lucene.queryParser.core.config.FieldConfig;
import org.apache.lucene.queryParser.core.config.QueryConfigHandler; import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.standard.StandardQueryParser;
import org.apache.lucene.queryParser.standard.processors.StandardQueryNodeProcessorPipeline; import org.apache.lucene.queryParser.standard.processors.StandardQueryNodeProcessorPipeline;
import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.MultiTermQuery.RewriteMethod;
/** /**
* This query configuration handler is used for almost every processor defined * This query configuration handler is used for almost every processor defined
* in the {@link StandardQueryNodeProcessorPipeline} processor pipeline. It holds * in the {@link StandardQueryNodeProcessorPipeline} processor pipeline. It holds
* attributes that reproduces the configuration that could be set on the old * configuration methods that reproduce the configuration methods that could be set on the old
* lucene 2.4 QueryParser class. <br/> * lucene 2.4 QueryParser class. <br/>
* *
* @see StandardQueryNodeProcessorPipeline * @see StandardQueryNodeProcessorPipeline
*/ */
public class StandardQueryConfigHandler extends QueryConfigHandler { public class StandardQueryConfigHandler extends QueryConfigHandler {
final public static class ConfigurationKeys {
/**
* Key used to set whether position increments is enabled
*
* @see StandardQueryParser#setEnablePositionIncrements(boolean)
* @see StandardQueryParser#getEnablePositionIncrements()
*/
final public static ConfigurationKey<Boolean> ENABLE_POSITION_INCREMENTS = ConfigurationKey.newInstance();
/**
* Key used to set whether expanded terms should be expanded
*
* @see StandardQueryParser#setLowercaseExpandedTerms(boolean)
* @see StandardQueryParser#getLowercaseExpandedTerms()
*/
final public static ConfigurationKey<Boolean> LOWERCASE_EXPANDED_TERMS = ConfigurationKey.newInstance();
/**
* Key used to set whether leading wildcards are supported
*
* @see StandardQueryParser#setAllowLeadingWildcard(boolean)
* @see StandardQueryParser#getAllowLeadingWildcard()
*/
final public static ConfigurationKey<Boolean> ALLOW_LEADING_WILDCARD = ConfigurationKey.newInstance();
/**
* Key used to set the {@link Analyzer} used for terms found in the query
*
* @see StandardQueryParser#setAnalyzer(Analyzer)
* @see StandardQueryParser#getAnalyzer()
*/
final public static ConfigurationKey<Analyzer> ANALYZER = ConfigurationKey.newInstance();
/**
* Key used to set the default boolean operator
*
* @see StandardQueryParser#setDefaultOperator(org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.Operator)
* @see StandardQueryParser#getDefaultOperator()
*/
final public static ConfigurationKey<Operator> DEFAULT_OPERATOR = ConfigurationKey.newInstance();
/**
* Key used to set the default phrase slop
*
* @see StandardQueryParser#setPhraseSlop(int)
* @see StandardQueryParser#getPhraseSlop()
*/
final public static ConfigurationKey<Integer> PHRASE_SLOP = ConfigurationKey.newInstance();
/**
* Key used to set the {@link Locale} used when parsing the query
*
* @see StandardQueryParser#setLocale(Locale)
* @see StandardQueryParser#getLocale()
*/
final public static ConfigurationKey<Locale> LOCALE = ConfigurationKey.newInstance();
/**
* Key used to set the {@link RewriteMethod} used when creating queries
*
* @see StandardQueryParser#setMultiTermRewriteMethod(org.apache.lucene.search.MultiTermQuery.RewriteMethod)
* @see StandardQueryParser#getMultiTermRewriteMethod()
*/
final public static ConfigurationKey<MultiTermQuery.RewriteMethod> MULTI_TERM_REWRITE_METHOD = ConfigurationKey.newInstance();
/**
* Key used to set the fields a query should be expanded to when the field
* is <code>null</code>
*
* @see StandardQueryParser#setMultiFields(CharSequence[])
* @see StandardQueryParser#getMultiFields(CharSequence[])
*/
final public static ConfigurationKey<CharSequence[]> MULTI_FIELDS = ConfigurationKey.newInstance();
/**
* Key used to set a field to boost map that is used to set the boost for each field
*
* @see StandardQueryParser#setFieldsBoost(Map)
* @see StandardQueryParser#getFieldsBoost()
*/
final public static ConfigurationKey<Map<String,Float>> FIELD_BOOST_MAP = ConfigurationKey.newInstance();
/**
* Key used to set a field to {@link Resolution} map that is used
* to normalize each date field value.
*
* @see StandardQueryParser#setDateResolutionMap(Map)
* @see StandardQueryParser#getDateResolutionMap()
*/
final public static ConfigurationKey<Map<CharSequence, DateTools.Resolution>> FIELD_DATE_RESOLUTION_MAP = ConfigurationKey.newInstance();
/**
* Key used to set the {@link FuzzyConfig} used to create fuzzy queries.
*
* @see StandardQueryParser#setFuzzyMinSim(float)
* @see StandardQueryParser#setFuzzyPrefixLength(int)
* @see StandardQueryParser#getFuzzyMinSim()
* @see StandardQueryParser#getFuzzyPrefixLength()
*/
final public static ConfigurationKey<FuzzyConfig> FUZZY_CONFIG = ConfigurationKey.newInstance();
/**
* Key used to set default {@link Resolution}.
*
* @see StandardQueryParser#setDateResolution(org.apache.lucene.document.DateTools.Resolution)
* @see StandardQueryParser#getDateResolution()
*/
final public static ConfigurationKey<DateTools.Resolution> DATE_RESOLUTION = ConfigurationKey.newInstance();
/**
* Key used to set the boost value in {@link FieldConfig} objects.
*
* @see StandardQueryParser#setFieldsBoost(Map)
* @see StandardQueryParser#getFieldsBoost()
*/
final public static ConfigurationKey<Float> BOOST = ConfigurationKey.newInstance();
}
public static enum Operator {
AND, OR;
}
public StandardQueryConfigHandler() { public StandardQueryConfigHandler() {
// Add listener that will build the FieldConfig attributes. // Add listener that will build the FieldConfig.
addFieldConfigListener(new FieldBoostMapFCListener(this)); addFieldConfigListener(new FieldBoostMapFCListener(this));
addFieldConfigListener(new FieldDateResolutionFCListener(this)); addFieldConfigListener(new FieldDateResolutionFCListener(this));
// Default Values // Default Values
addAttribute(DefaultOperatorAttribute.class); set(ConfigurationKeys.ALLOW_LEADING_WILDCARD, false); // default in 2.9
addAttribute(AnalyzerAttribute.class); set(ConfigurationKeys.ANALYZER, null); //default value 2.4
addAttribute(FuzzyAttribute.class); set(ConfigurationKeys.DEFAULT_OPERATOR, Operator.OR);
addAttribute(LowercaseExpandedTermsAttribute.class); set(ConfigurationKeys.PHRASE_SLOP, 0); //default value 2.4
addAttribute(MultiTermRewriteMethodAttribute.class); set(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS, true); //default value 2.4
addAttribute(AllowLeadingWildcardAttribute.class); set(ConfigurationKeys.ENABLE_POSITION_INCREMENTS, false); //default value 2.4
addAttribute(PositionIncrementsAttribute.class); set(ConfigurationKeys.FIELD_BOOST_MAP, new LinkedHashMap<String, Float>());
addAttribute(LocaleAttribute.class); set(ConfigurationKeys.FUZZY_CONFIG, new FuzzyConfig());
addAttribute(DefaultPhraseSlopAttribute.class); set(ConfigurationKeys.LOCALE, Locale.getDefault());
addAttribute(MultiTermRewriteMethodAttribute.class); set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
set(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP, new HashMap<CharSequence, DateTools.Resolution>());
} }

View File

@ -24,7 +24,7 @@
<h2>Standard Lucene Query Configuration</h2> <h2>Standard Lucene Query Configuration</h2>
<p> <p>
The package org.apache.lucene.queryParser.standard.config contains the Lucene The package org.apache.lucene.queryParser.standard.config contains the Lucene
query configuration handler and all the attributes used by it. This configuration query configuration handler (StandardQueryConfigHandler). This configuration
handler reproduces almost everything that could be set on the old query parser. handler reproduces almost everything that could be set on the old query parser.
</p> </p>
<p> <p>

View File

@ -26,18 +26,18 @@ import org.apache.lucene.queryParser.core.messages.QueryParserMessages;
import org.apache.lucene.queryParser.core.nodes.QueryNode; import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl;
import org.apache.lucene.queryParser.core.util.UnescapedCharSequence; import org.apache.lucene.queryParser.core.util.UnescapedCharSequence;
import org.apache.lucene.queryParser.standard.config.AllowLeadingWildcardAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode; import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode;
import org.apache.lucene.queryParser.standard.parser.EscapeQuerySyntaxImpl; import org.apache.lucene.queryParser.standard.parser.EscapeQuerySyntaxImpl;
/** /**
* This processor verifies if the attribute * This processor verifies if
* {@link AllowLeadingWildcardAttribute} is defined in the * {@link ConfigurationKeys#ALLOW_LEADING_WILDCARD} is defined in the
* {@link QueryConfigHandler}. If it is and leading wildcard is not allowed, it * {@link QueryConfigHandler}. If it is and leading wildcard is not allowed, it
* looks for every {@link WildcardQueryNode} contained in the query node tree * looks for every {@link WildcardQueryNode} contained in the query node tree
* and throws an exception if any of them has a leading wildcard ('*' or '?'). <br/> * and throws an exception if any of them has a leading wildcard ('*' or '?'). <br/>
* *
* @see AllowLeadingWildcardAttribute * @see ConfigurationKeys#ALLOW_LEADING_WILDCARD
*/ */
public class AllowLeadingWildcardProcessor extends QueryNodeProcessorImpl { public class AllowLeadingWildcardProcessor extends QueryNodeProcessorImpl {
@ -47,11 +47,11 @@ public class AllowLeadingWildcardProcessor extends QueryNodeProcessorImpl {
@Override @Override
public QueryNode process(QueryNode queryTree) throws QueryNodeException { public QueryNode process(QueryNode queryTree) throws QueryNodeException {
Boolean allowsLeadingWildcard = getQueryConfigHandler().get(ConfigurationKeys.ALLOW_LEADING_WILDCARD);
if (getQueryConfigHandler().hasAttribute(AllowLeadingWildcardAttribute.class)) { if (allowsLeadingWildcard != null) {
AllowLeadingWildcardAttribute alwAttr= getQueryConfigHandler().getAttribute(AllowLeadingWildcardAttribute.class); if (!allowsLeadingWildcard) {
if (!alwAttr.isAllowLeadingWildcard()) {
return super.process(queryTree); return super.process(queryTree);
} }

View File

@ -40,14 +40,14 @@ import org.apache.lucene.queryParser.core.nodes.QuotedFieldQueryNode;
import org.apache.lucene.queryParser.core.nodes.TextableQueryNode; import org.apache.lucene.queryParser.core.nodes.TextableQueryNode;
import org.apache.lucene.queryParser.core.nodes.TokenizedPhraseQueryNode; import org.apache.lucene.queryParser.core.nodes.TokenizedPhraseQueryNode;
import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl;
import org.apache.lucene.queryParser.standard.config.AnalyzerAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.PositionIncrementsAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
import org.apache.lucene.queryParser.standard.nodes.MultiPhraseQueryNode; import org.apache.lucene.queryParser.standard.nodes.MultiPhraseQueryNode;
import org.apache.lucene.queryParser.standard.nodes.StandardBooleanQueryNode; import org.apache.lucene.queryParser.standard.nodes.StandardBooleanQueryNode;
import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode; import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode;
/** /**
* This processor verifies if the attribute {@link AnalyzerQueryNodeProcessor} * This processor verifies if {@link ConfigurationKeys#ANALYZER}
* is defined in the {@link QueryConfigHandler}. If it is and the analyzer is * is defined in the {@link QueryConfigHandler}. If it is and the analyzer is
* not <code>null</code>, it looks for every {@link FieldQueryNode} that is not * not <code>null</code>, it looks for every {@link FieldQueryNode} that is not
* {@link WildcardQueryNode}, {@link FuzzyQueryNode} or * {@link WildcardQueryNode}, {@link FuzzyQueryNode} or
@ -64,6 +64,7 @@ import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode;
* If no term is returned by the analyzer a {@link NoTokenFoundQueryNode} object * If no term is returned by the analyzer a {@link NoTokenFoundQueryNode} object
* is returned. <br/> * is returned. <br/>
* *
* @see ConfigurationKeys#ANALYZER
* @see Analyzer * @see Analyzer
* @see TokenStream * @see TokenStream
*/ */
@ -79,24 +80,15 @@ public class AnalyzerQueryNodeProcessor extends QueryNodeProcessorImpl {
@Override @Override
public QueryNode process(QueryNode queryTree) throws QueryNodeException { public QueryNode process(QueryNode queryTree) throws QueryNodeException {
Analyzer analyzer = getQueryConfigHandler().get(ConfigurationKeys.ANALYZER);
if (getQueryConfigHandler().hasAttribute(AnalyzerAttribute.class)) {
if (analyzer != null) {
this.analyzer = getQueryConfigHandler().getAttribute( this.analyzer = analyzer;
AnalyzerAttribute.class).getAnalyzer();
this.positionIncrementsEnabled = false; this.positionIncrementsEnabled = false;
Boolean positionIncrementsEnabled = getQueryConfigHandler().get(ConfigurationKeys.ENABLE_POSITION_INCREMENTS);
if (getQueryConfigHandler().hasAttribute( if (positionIncrementsEnabled != null) {
PositionIncrementsAttribute.class)) { this.positionIncrementsEnabled = positionIncrementsEnabled;
if (getQueryConfigHandler().getAttribute(
PositionIncrementsAttribute.class).isPositionIncrementsEnabled()) {
this.positionIncrementsEnabled = true;
}
} }
if (this.analyzer != null) { if (this.analyzer != null) {

View File

@ -27,14 +27,14 @@ import org.apache.lucene.queryParser.core.nodes.FieldableNode;
import org.apache.lucene.queryParser.core.nodes.QueryNode; import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl;
import org.apache.lucene.queryParser.core.util.StringUtils; import org.apache.lucene.queryParser.core.util.StringUtils;
import org.apache.lucene.queryParser.standard.config.BoostAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
/** /**
* This processor iterates the query node tree looking for every * This processor iterates the query node tree looking for every
* {@link FieldableNode} that has the attribute {@link BoostAttribute} in its * {@link FieldableNode} that has {@link ConfigurationKeys#BOOST} in its
* config. If there is, the boost is applied to that {@link FieldableNode}. <br/> * config. If there is, the boost is applied to that {@link FieldableNode}. <br/>
* *
* @see BoostAttribute * @see ConfigurationKeys#BOOST
* @see QueryConfigHandler * @see QueryConfigHandler
* @see FieldableNode * @see FieldableNode
*/ */
@ -53,10 +53,12 @@ public class BoostQueryNodeProcessor extends QueryNodeProcessorImpl {
CharSequence field = fieldNode.getField(); CharSequence field = fieldNode.getField();
FieldConfig fieldConfig = config.getFieldConfig(StringUtils.toString(field)); FieldConfig fieldConfig = config.getFieldConfig(StringUtils.toString(field));
if (fieldConfig != null && fieldConfig.hasAttribute(BoostAttribute.class)) { if (fieldConfig != null) {
BoostAttribute boostAttr = fieldConfig.getAttribute(BoostAttribute.class); Float boost = fieldConfig.get(ConfigurationKeys.BOOST);
return new BoostQueryNode(node, boostAttr.getBoost()); if (boost != null) {
return new BoostQueryNode(node, boost);
}
} }

View File

@ -25,19 +25,20 @@ import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.core.nodes.SlopQueryNode; import org.apache.lucene.queryParser.core.nodes.SlopQueryNode;
import org.apache.lucene.queryParser.core.nodes.TokenizedPhraseQueryNode; import org.apache.lucene.queryParser.core.nodes.TokenizedPhraseQueryNode;
import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl;
import org.apache.lucene.queryParser.standard.config.DefaultPhraseSlopAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
import org.apache.lucene.queryParser.standard.nodes.MultiPhraseQueryNode; import org.apache.lucene.queryParser.standard.nodes.MultiPhraseQueryNode;
/** /**
* This processor verifies if the attribute {@link DefaultPhraseSlopAttribute} * This processor verifies if {@link ConfigurationKeys#PHRASE_SLOP}
* is defined in the {@link QueryConfigHandler}. If it is, it looks for every * is defined in the {@link QueryConfigHandler}. If it is, it looks for every
* {@link TokenizedPhraseQueryNode} and {@link MultiPhraseQueryNode} that does * {@link TokenizedPhraseQueryNode} and {@link MultiPhraseQueryNode} that does
* not have any {@link SlopQueryNode} applied to it and creates an * not have any {@link SlopQueryNode} applied to it and creates an
* {@link SlopQueryNode} and apply to it. The new {@link SlopQueryNode} has the * {@link SlopQueryNode} and apply to it. The new {@link SlopQueryNode} has the
* same slop value defined in the attribute. <br/> * same slop value defined in the configuration. <br/>
* *
* @see SlopQueryNode * @see SlopQueryNode
* @see DefaultPhraseSlopAttribute * @see ConfigurationKeys#PHRASE_SLOP
*/ */
public class DefaultPhraseSlopQueryNodeProcessor extends QueryNodeProcessorImpl { public class DefaultPhraseSlopQueryNodeProcessor extends QueryNodeProcessorImpl {
@ -54,10 +55,10 @@ public class DefaultPhraseSlopQueryNodeProcessor extends QueryNodeProcessorImpl
QueryConfigHandler queryConfig = getQueryConfigHandler(); QueryConfigHandler queryConfig = getQueryConfigHandler();
if (queryConfig != null) { if (queryConfig != null) {
Integer defaultPhraseSlop = queryConfig.get(ConfigurationKeys.PHRASE_SLOP);
if (queryConfig.hasAttribute(DefaultPhraseSlopAttribute.class)) {
this.defaultPhraseSlop = queryConfig.getAttribute( if (defaultPhraseSlop != null) {
DefaultPhraseSlopAttribute.class).getDefaultPhraseSlop(); this.defaultPhraseSlop = defaultPhraseSlop;
return super.process(queryTree); return super.process(queryTree);

View File

@ -24,17 +24,20 @@ import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
import org.apache.lucene.queryParser.core.nodes.FuzzyQueryNode; import org.apache.lucene.queryParser.core.nodes.FuzzyQueryNode;
import org.apache.lucene.queryParser.core.nodes.QueryNode; import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl;
import org.apache.lucene.queryParser.standard.config.FuzzyAttribute; import org.apache.lucene.queryParser.standard.config.FuzzyConfig;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
import org.apache.lucene.search.FuzzyQuery; import org.apache.lucene.search.FuzzyQuery;
/** /**
* This processor iterates the query node tree looking for every * This processor iterates the query node tree looking for every
* {@link FuzzyQueryNode}, when this kind of node is found, it checks on the * {@link FuzzyQueryNode}, when this kind of node is found, it checks on the
* query configuration for {@link FuzzyAttribute}, gets the fuzzy prefix length * query configuration for
* and default similarity from it and set to the fuzzy node. For more * {@link ConfigurationKeys#FUZZY_CONFIG}, gets the
* information about fuzzy prefix length check: {@link FuzzyQuery}. <br/> * fuzzy prefix length and default similarity from it and set to the fuzzy node.
* For more information about fuzzy prefix length check: {@link FuzzyQuery}. <br/>
* *
* @see FuzzyAttribute * @see ConfigurationKeys#FUZZY_CONFIG
* @see FuzzyQuery * @see FuzzyQuery
* @see FuzzyQueryNode * @see FuzzyQueryNode
*/ */
@ -54,18 +57,17 @@ public class FuzzyQueryNodeProcessor extends QueryNodeProcessorImpl {
FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) node; FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) node;
QueryConfigHandler config = getQueryConfigHandler(); QueryConfigHandler config = getQueryConfigHandler();
if (config != null && config.hasAttribute(FuzzyAttribute.class)) { FuzzyConfig fuzzyConfig = null;
FuzzyAttribute fuzzyAttr = config.getAttribute(FuzzyAttribute.class);
fuzzyNode.setPrefixLength(fuzzyAttr.getPrefixLength()); if (config != null && (fuzzyConfig = config.get(ConfigurationKeys.FUZZY_CONFIG)) != null) {
fuzzyNode.setPrefixLength(fuzzyConfig.getPrefixLength());
if (fuzzyNode.getSimilarity() < 0) { if (fuzzyNode.getSimilarity() < 0) {
fuzzyNode.setSimilarity(fuzzyAttr.getFuzzyMinSimilarity()); fuzzyNode.setSimilarity(fuzzyConfig.getMinSimilarity());
} }
} else if (fuzzyNode.getSimilarity() < 0) { } else if (fuzzyNode.getSimilarity() < 0) {
throw new IllegalArgumentException("No " throw new IllegalArgumentException("No FUZZY_CONFIG set in the config");
+ FuzzyAttribute.class.getName() + " set in the config");
} }
} }

View File

@ -31,8 +31,9 @@ import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.core.nodes.ModifierQueryNode.Modifier; import org.apache.lucene.queryParser.core.nodes.ModifierQueryNode.Modifier;
import org.apache.lucene.queryParser.core.parser.SyntaxParser; import org.apache.lucene.queryParser.core.parser.SyntaxParser;
import org.apache.lucene.queryParser.core.processors.QueryNodeProcessor; import org.apache.lucene.queryParser.core.processors.QueryNodeProcessor;
import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute.Operator; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.Operator;
import org.apache.lucene.queryParser.standard.nodes.BooleanModifierNode; import org.apache.lucene.queryParser.standard.nodes.BooleanModifierNode;
/** /**
@ -64,14 +65,14 @@ public class GroupQueryNodeProcessor implements QueryNodeProcessor {
} }
public QueryNode process(QueryNode queryTree) throws QueryNodeException { public QueryNode process(QueryNode queryTree) throws QueryNodeException {
Operator defaultOperator = getQueryConfigHandler().get(ConfigurationKeys.DEFAULT_OPERATOR);
if (!getQueryConfigHandler().hasAttribute(DefaultOperatorAttribute.class)) {
if (defaultOperator == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"DefaultOperatorAttribute should be set on the QueryConfigHandler"); "DEFAULT_OPERATOR should be set on the QueryConfigHandler");
} }
this.usingAnd = Operator.AND == getQueryConfigHandler() this.usingAnd = StandardQueryConfigHandler.Operator.AND == defaultOperator;
.getAttribute(DefaultOperatorAttribute.class).getOperator();
if (queryTree instanceof GroupQueryNode) { if (queryTree instanceof GroupQueryNode) {
queryTree = ((GroupQueryNode) queryTree).getChild(); queryTree = ((GroupQueryNode) queryTree).getChild();

View File

@ -27,19 +27,20 @@ import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.core.nodes.TextableQueryNode; import org.apache.lucene.queryParser.core.nodes.TextableQueryNode;
import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl;
import org.apache.lucene.queryParser.core.util.UnescapedCharSequence; import org.apache.lucene.queryParser.core.util.UnescapedCharSequence;
import org.apache.lucene.queryParser.standard.config.LowercaseExpandedTermsAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
import org.apache.lucene.queryParser.standard.nodes.RegexpQueryNode; import org.apache.lucene.queryParser.standard.nodes.RegexpQueryNode;
import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode; import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode;
/** /**
* This processor verifies if the attribute * This processor verifies if
* {@link LowercaseExpandedTermsAttribute} is defined in the * {@link ConfigurationKeys#LOWERCASE_EXPANDED_TERMS} is defined in the
* {@link QueryConfigHandler}. If it is and the expanded terms should be * {@link QueryConfigHandler}. If it is and the expanded terms should be
* lower-cased, it looks for every {@link WildcardQueryNode}, * lower-cased, it looks for every {@link WildcardQueryNode},
* {@link FuzzyQueryNode} and {@link ParametricQueryNode} and lower-case its * {@link FuzzyQueryNode} and {@link ParametricQueryNode} and lower-case its
* term. <br/> * term. <br/>
* *
* @see LowercaseExpandedTermsAttribute * @see ConfigurationKeys#LOWERCASE_EXPANDED_TERMS
*/ */
public class LowercaseExpandedTermsQueryNodeProcessor extends public class LowercaseExpandedTermsQueryNodeProcessor extends
QueryNodeProcessorImpl { QueryNodeProcessorImpl {
@ -50,17 +51,10 @@ public class LowercaseExpandedTermsQueryNodeProcessor extends
@Override @Override
public QueryNode process(QueryNode queryTree) throws QueryNodeException { public QueryNode process(QueryNode queryTree) throws QueryNodeException {
Boolean lowercaseExpandedTerms = getQueryConfigHandler().get(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS);
if (getQueryConfigHandler().hasAttribute( if (lowercaseExpandedTerms != null && lowercaseExpandedTerms) {
LowercaseExpandedTermsAttribute.class)) { return super.process(queryTree);
if (getQueryConfigHandler().getAttribute(
LowercaseExpandedTermsAttribute.class).isLowercaseExpandedTerms()) {
return super.process(queryTree);
}
} }
return queryTree; return queryTree;

View File

@ -27,7 +27,8 @@ import org.apache.lucene.queryParser.core.nodes.FieldableNode;
import org.apache.lucene.queryParser.core.nodes.GroupQueryNode; import org.apache.lucene.queryParser.core.nodes.GroupQueryNode;
import org.apache.lucene.queryParser.core.nodes.QueryNode; import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl;
import org.apache.lucene.queryParser.standard.config.MultiFieldAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
/** /**
* This processor is used to expand terms so the query looks for the same term * This processor is used to expand terms so the query looks for the same term
@ -35,13 +36,13 @@ import org.apache.lucene.queryParser.standard.config.MultiFieldAttribute;
* <br/> * <br/>
* This processor looks for every {@link FieldableNode} contained in the query * This processor looks for every {@link FieldableNode} contained in the query
* node tree. If a {@link FieldableNode} is found, it checks if there is a * node tree. If a {@link FieldableNode} is found, it checks if there is a
* {@link MultiFieldAttribute} defined in the {@link QueryConfigHandler}. If * {@link ConfigurationKeys#MULTI_FIELDS} defined in the {@link QueryConfigHandler}. If
* there is, the {@link FieldableNode} is cloned N times and the clones are * there is, the {@link FieldableNode} is cloned N times and the clones are
* added to a {@link BooleanQueryNode} together with the original node. N is * added to a {@link BooleanQueryNode} together with the original node. N is
* defined by the number of fields that it will be expanded to. The * defined by the number of fields that it will be expanded to. The
* {@link BooleanQueryNode} is returned. <br/> * {@link BooleanQueryNode} is returned. <br/>
* *
* @see MultiFieldAttribute * @see ConfigurationKeys#MULTI_FIELDS
*/ */
public class MultiFieldQueryNodeProcessor extends QueryNodeProcessorImpl { public class MultiFieldQueryNodeProcessor extends QueryNodeProcessorImpl {
@ -78,15 +79,13 @@ public class MultiFieldQueryNodeProcessor extends QueryNodeProcessorImpl {
FieldableNode fieldNode = (FieldableNode) node; FieldableNode fieldNode = (FieldableNode) node;
if (fieldNode.getField() == null) { if (fieldNode.getField() == null) {
CharSequence[] fields = getQueryConfigHandler().get(ConfigurationKeys.MULTI_FIELDS);
if (!getQueryConfigHandler().hasAttribute(MultiFieldAttribute.class)) { if (fields == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"MultiFieldAttribute should be set on the QueryConfigHandler"); "StandardQueryConfigHandler.ConfigurationKeys.MULTI_FIELDS should be set on the QueryConfigHandler");
} }
CharSequence[] fields = getQueryConfigHandler().getAttribute(
MultiFieldAttribute.class).getFields();
if (fields != null && fields.length > 0) { if (fields != null && fields.length > 0) {
fieldNode.setField(fields[0]); fieldNode.setField(fields[0]);

View File

@ -22,7 +22,7 @@ import java.util.List;
import org.apache.lucene.queryParser.core.nodes.ParametricRangeQueryNode; import org.apache.lucene.queryParser.core.nodes.ParametricRangeQueryNode;
import org.apache.lucene.queryParser.core.nodes.QueryNode; import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl;
import org.apache.lucene.queryParser.standard.config.MultiTermRewriteMethodAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
import org.apache.lucene.queryParser.standard.nodes.RegexpQueryNode; import org.apache.lucene.queryParser.standard.nodes.RegexpQueryNode;
import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode; import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode;
import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.MultiTermQuery;
@ -35,6 +35,8 @@ import org.apache.lucene.search.MultiTermQuery;
*/ */
public class MultiTermRewriteMethodProcessor extends QueryNodeProcessorImpl { public class MultiTermRewriteMethodProcessor extends QueryNodeProcessorImpl {
public static final String TAG_ID = "MultiTermRewriteMethodConfiguration";
@Override @Override
protected QueryNode postProcessNode(QueryNode node) { protected QueryNode postProcessNode(QueryNode node) {
@ -42,21 +44,18 @@ public class MultiTermRewriteMethodProcessor extends QueryNodeProcessorImpl {
// PrefixWildcardQueryNode // PrefixWildcardQueryNode
if (node instanceof WildcardQueryNode if (node instanceof WildcardQueryNode
|| node instanceof ParametricRangeQueryNode || node instanceof RegexpQueryNode) { || node instanceof ParametricRangeQueryNode || node instanceof RegexpQueryNode) {
MultiTermQuery.RewriteMethod rewriteMethod = getQueryConfigHandler().get(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD);
if (!getQueryConfigHandler().hasAttribute( if (rewriteMethod == null) {
MultiTermRewriteMethodAttribute.class)) { // This should not happen, this configuration is set in the
// This should not happen, this attribute is created in the
// StandardQueryConfigHandler // StandardQueryConfigHandler
throw new IllegalArgumentException( throw new IllegalArgumentException(
"MultiTermRewriteMethodAttribute should be set on the QueryConfigHandler"); "StandardQueryConfigHandler.ConfigurationKeys.MULTI_TERM_REWRITE_METHOD should be set on the QueryConfigHandler");
} }
// read the attribute value and use a TAG to take the value to the Builder // use a TAG to take the value to the Builder
MultiTermQuery.RewriteMethod rewriteMethod = getQueryConfigHandler() node.setTag(MultiTermRewriteMethodProcessor.TAG_ID, rewriteMethod);
.getAttribute(MultiTermRewriteMethodAttribute.class)
.getMultiTermRewriteMethod();
node.setTag(MultiTermRewriteMethodAttribute.TAG_ID, rewriteMethod);
} }

View File

@ -33,8 +33,8 @@ import org.apache.lucene.queryParser.core.nodes.ParametricRangeQueryNode;
import org.apache.lucene.queryParser.core.nodes.QueryNode; import org.apache.lucene.queryParser.core.nodes.QueryNode;
import org.apache.lucene.queryParser.core.nodes.ParametricQueryNode.CompareOperator; import org.apache.lucene.queryParser.core.nodes.ParametricQueryNode.CompareOperator;
import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl;
import org.apache.lucene.queryParser.standard.config.DateResolutionAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.LocaleAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
import org.apache.lucene.queryParser.standard.nodes.RangeQueryNode; import org.apache.lucene.queryParser.standard.nodes.RangeQueryNode;
/** /**
@ -45,16 +45,16 @@ import org.apache.lucene.queryParser.standard.nodes.RangeQueryNode;
* value, it will only create the {@link RangeQueryNode} using the non-parsed * value, it will only create the {@link RangeQueryNode} using the non-parsed
* values. <br/> * values. <br/>
* <br/> * <br/>
* If a {@link LocaleAttribute} is defined in the {@link QueryConfigHandler} it * If a {@link ConfigurationKeys#LOCALE} is defined in the {@link QueryConfigHandler} it
* will be used to parse the date, otherwise {@link Locale#getDefault()} will be * will be used to parse the date, otherwise {@link Locale#getDefault()} will be
* used. <br/> * used. <br/>
* <br/> * <br/>
* If a {@link DateResolutionAttribute} is defined and the {@link Resolution} is * If a {@link ConfigurationKeys#DATE_RESOLUTION} is defined and the {@link Resolution} is
* not <code>null</code> it will also be used to parse the date value. <br/> * not <code>null</code> it will also be used to parse the date value. <br/>
* <br/> * <br/>
* *
* @see DateResolutionAttribute * @see ConfigurationKeys#DATE_RESOLUTION
* @see LocaleAttribute * @see ConfigurationKeys#LOCALE
* @see RangeQueryNode * @see RangeQueryNode
* @see ParametricRangeQueryNode * @see ParametricRangeQueryNode
*/ */
@ -71,15 +71,13 @@ public class ParametricRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
ParametricRangeQueryNode parametricRangeNode = (ParametricRangeQueryNode) node; ParametricRangeQueryNode parametricRangeNode = (ParametricRangeQueryNode) node;
ParametricQueryNode upper = parametricRangeNode.getUpperBound(); ParametricQueryNode upper = parametricRangeNode.getUpperBound();
ParametricQueryNode lower = parametricRangeNode.getLowerBound(); ParametricQueryNode lower = parametricRangeNode.getLowerBound();
Locale locale = Locale.getDefault();
DateTools.Resolution dateRes = null; DateTools.Resolution dateRes = null;
boolean inclusive = false; boolean inclusive = false;
Locale locale = getQueryConfigHandler().get(ConfigurationKeys.LOCALE);
if (getQueryConfigHandler().hasAttribute(LocaleAttribute.class)) { if (locale == null) {
locale = Locale.getDefault();
locale = getQueryConfigHandler().getAttribute(LocaleAttribute.class)
.getLocale();
} }
CharSequence field = parametricRangeNode.getField(); CharSequence field = parametricRangeNode.getField();
@ -93,14 +91,7 @@ public class ParametricRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
.getFieldConfig(fieldStr); .getFieldConfig(fieldStr);
if (fieldConfig != null) { if (fieldConfig != null) {
dateRes = fieldConfig.get(ConfigurationKeys.DATE_RESOLUTION);
if (fieldConfig.hasAttribute(DateResolutionAttribute.class)) {
dateRes = fieldConfig.getAttribute(DateResolutionAttribute.class)
.getDateResolution();
}
} }
if (upper.getOperator() == CompareOperator.LE) { if (upper.getOperator() == CompareOperator.LE) {

View File

@ -108,8 +108,7 @@ builder that will transform the QueryNode into Lucene Query object.
</dl> </dl>
<p> <p>
Furthermore, the query parser uses flexible configuration objects, which Furthermore, the query parser uses flexible configuration objects. It also uses message classes that
are based on AttributeSource/Attribute. It also uses message classes that
allow to attach resource bundles. This makes it possible to translate allow to attach resource bundles. This makes it possible to translate
messages, which is an important feature of a query parser. messages, which is an important feature of a query parser.
</p> </p>

View File

@ -38,7 +38,7 @@ import org.apache.lucene.document.DateTools;
import org.apache.lucene.queryParser.TestQueryParser; import org.apache.lucene.queryParser.TestQueryParser;
import org.apache.lucene.queryParser.core.QueryNodeException; import org.apache.lucene.queryParser.core.QueryNodeException;
import org.apache.lucene.queryParser.core.QueryNodeParseException; import org.apache.lucene.queryParser.core.QueryNodeParseException;
import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute.Operator; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.parser.ParseException; import org.apache.lucene.queryParser.standard.parser.ParseException;
import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.FuzzyQuery; import org.apache.lucene.search.FuzzyQuery;
@ -128,7 +128,7 @@ public class TestPrecedenceQueryParser extends LuceneTestCase {
a = new MockAnalyzer(random, MockTokenizer.SIMPLE, true); a = new MockAnalyzer(random, MockTokenizer.SIMPLE, true);
PrecedenceQueryParser qp = new PrecedenceQueryParser(); PrecedenceQueryParser qp = new PrecedenceQueryParser();
qp.setAnalyzer(a); qp.setAnalyzer(a);
qp.setDefaultOperator(Operator.OR); qp.setDefaultOperator(StandardQueryConfigHandler.Operator.OR);
return qp; return qp;
} }
@ -174,7 +174,7 @@ public class TestPrecedenceQueryParser extends LuceneTestCase {
a = new MockAnalyzer(random, MockTokenizer.SIMPLE, true); a = new MockAnalyzer(random, MockTokenizer.SIMPLE, true);
PrecedenceQueryParser qp = new PrecedenceQueryParser(); PrecedenceQueryParser qp = new PrecedenceQueryParser();
qp.setAnalyzer(a); qp.setAnalyzer(a);
qp.setDefaultOperator(Operator.AND); qp.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);
return qp.parse(query, "field"); return qp.parse(query, "field");
} }
@ -234,11 +234,11 @@ public class TestPrecedenceQueryParser extends LuceneTestCase {
PrecedenceQueryParser qp = new PrecedenceQueryParser(); PrecedenceQueryParser qp = new PrecedenceQueryParser();
qp.setAnalyzer(new MockAnalyzer(random)); qp.setAnalyzer(new MockAnalyzer(random));
// make sure OR is the default: // make sure OR is the default:
assertEquals(Operator.OR, qp.getDefaultOperator()); assertEquals(StandardQueryConfigHandler.Operator.OR, qp.getDefaultOperator());
qp.setDefaultOperator(Operator.AND); qp.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);
assertEquals(Operator.AND, qp.getDefaultOperator()); assertEquals(StandardQueryConfigHandler.Operator.AND, qp.getDefaultOperator());
qp.setDefaultOperator(Operator.OR); qp.setDefaultOperator(StandardQueryConfigHandler.Operator.OR);
assertEquals(Operator.OR, qp.getDefaultOperator()); assertEquals(StandardQueryConfigHandler.Operator.OR, qp.getDefaultOperator());
assertQueryEquals("a OR !b", null, "a -b"); assertQueryEquals("a OR !b", null, "a -b");
assertQueryEquals("a OR ! b", null, "a -b"); assertQueryEquals("a OR ! b", null, "a -b");
@ -607,7 +607,7 @@ public class TestPrecedenceQueryParser extends LuceneTestCase {
query2 = parser.parse("A (-B +C)", "field"); query2 = parser.parse("A (-B +C)", "field");
assertEquals(query1, query2); assertEquals(query1, query2);
parser.setDefaultOperator(Operator.AND); parser.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);
query1 = parser.parse("A AND B OR C AND D", "field"); query1 = parser.parse("A AND B OR C AND D", "field");
query2 = parser.parse("(A AND B) OR (C AND D)", "field"); query2 = parser.parse("(A AND B) OR (C AND D)", "field");
assertEquals(query1, query2); assertEquals(query1, query2);

View File

@ -17,6 +17,7 @@ package org.apache.lucene.queryParser.spans;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.lucene.queryParser.core.config.ConfigurationKey;
import org.apache.lucene.queryParser.core.config.FieldConfig; import org.apache.lucene.queryParser.core.config.FieldConfig;
import org.apache.lucene.queryParser.core.config.QueryConfigHandler; import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
@ -27,9 +28,11 @@ import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
* It does not return any configuration for a field in specific. * It does not return any configuration for a field in specific.
*/ */
public class SpansQueryConfigHandler extends QueryConfigHandler { public class SpansQueryConfigHandler extends QueryConfigHandler {
final public static ConfigurationKey<String> UNIQUE_FIELD = ConfigurationKey.newInstance();
public SpansQueryConfigHandler() { public SpansQueryConfigHandler() {
addAttribute(UniqueFieldAttribute.class); // empty constructor
} }
@Override @Override

View File

@ -127,11 +127,10 @@ public class TestSpanQueryParser extends LuceneTestCase {
return getSpanQuery("", query); return getSpanQuery("", query);
} }
public SpanQuery getSpanQuery(CharSequence uniqueField, CharSequence query) public SpanQuery getSpanQuery(String uniqueField, CharSequence query)
throws QueryNodeException { throws QueryNodeException {
UniqueFieldAttribute uniqueFieldAtt = this.spanQueryConfigHandler
.getAttribute(UniqueFieldAttribute.class); this.spanQueryConfigHandler.set(SpansQueryConfigHandler.UNIQUE_FIELD, uniqueField);
uniqueFieldAtt.setUniqueField(uniqueField);
QueryNode queryTree = this.queryParser.parse(query, "defaultField"); QueryNode queryTree = this.queryParser.parse(query, "defaultField");
queryTree = this.spanProcessorPipeline.process(queryTree); queryTree = this.spanProcessorPipeline.process(queryTree);

View File

@ -104,9 +104,7 @@ public class TestSpanQueryParserSimpleSample extends LuceneTestCase {
// create a config handler with a attribute used in // create a config handler with a attribute used in
// UniqueFieldQueryNodeProcessor // UniqueFieldQueryNodeProcessor
QueryConfigHandler spanQueryConfigHandler = new SpansQueryConfigHandler(); QueryConfigHandler spanQueryConfigHandler = new SpansQueryConfigHandler();
UniqueFieldAttribute uniqueFieldAtt = spanQueryConfigHandler spanQueryConfigHandler.set(SpansQueryConfigHandler.UNIQUE_FIELD, "index");
.getAttribute(UniqueFieldAttribute.class);
uniqueFieldAtt.setUniqueField("index");
// set up the processor pipeline with the ConfigHandler // set up the processor pipeline with the ConfigHandler
// and create the pipeline for this simple demo // and create the pipeline for this simple demo

View File

@ -57,14 +57,12 @@ public class UniqueFieldQueryNodeProcessor extends QueryNodeProcessorImpl {
"A config handler is expected by the processor UniqueFieldQueryNodeProcessor!"); "A config handler is expected by the processor UniqueFieldQueryNodeProcessor!");
} }
if (!queryConfig.hasAttribute(UniqueFieldAttribute.class)) { if (!queryConfig.has(SpansQueryConfigHandler.UNIQUE_FIELD)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"UniqueFieldAttribute should be defined in the config handler!"); "UniqueFieldAttribute should be defined in the config handler!");
} }
CharSequence uniqueField = queryConfig.getAttribute( String uniqueField = queryConfig.get(SpansQueryConfigHandler.UNIQUE_FIELD);
UniqueFieldAttribute.class).getUniqueField();
fieldNode.setField(uniqueField); fieldNode.setField(uniqueField);
} }

View File

@ -28,7 +28,8 @@ import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.TypeAttribute; import org.apache.lucene.analysis.tokenattributes.TypeAttribute;
import org.apache.lucene.queryParser.core.QueryNodeException; import org.apache.lucene.queryParser.core.QueryNodeException;
import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute.Operator; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.Operator;
import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase;
/** /**
@ -102,7 +103,7 @@ public class TestMultiAnalyzerQPHelper extends LuceneTestCase {
qp.setDefaultPhraseSlop(0); qp.setDefaultPhraseSlop(0);
// non-default operator: // non-default operator:
qp.setDefaultOperator(Operator.AND); qp.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);
assertEquals("+(multi multi2) +foo", qp.parse("multi foo", "").toString()); assertEquals("+(multi multi2) +foo", qp.parse("multi foo", "").toString());
} }

View File

@ -28,7 +28,8 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.queryParser.core.QueryNodeException; import org.apache.lucene.queryParser.core.QueryNodeException;
import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute.Operator; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.Operator;
import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
@ -133,7 +134,7 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
assertEquals("(b:one t:one) f:two", q.toString()); assertEquals("(b:one t:one) f:two", q.toString());
// AND mode: // AND mode:
mfqp.setDefaultOperator(Operator.AND); mfqp.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);
q = mfqp.parse("one two", null); q = mfqp.parse("one two", null);
assertEquals("+(b:one t:one) +(b:two t:two)", q.toString()); assertEquals("+(b:one t:one) +(b:two t:two)", q.toString());
q = mfqp.parse("\"aa bb cc\" \"dd ee\"", null); q = mfqp.parse("\"aa bb cc\" \"dd ee\"", null);
@ -329,7 +330,7 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
mfqp.setMultiFields(new String[] { "body" }); mfqp.setMultiFields(new String[] { "body" });
mfqp.setAnalyzer(analyzer); mfqp.setAnalyzer(analyzer);
mfqp.setDefaultOperator(Operator.AND); mfqp.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);
Query q = mfqp.parse("the footest", null); Query q = mfqp.parse("the footest", null);
IndexSearcher is = new IndexSearcher(ramDir, true); IndexSearcher is = new IndexSearcher(ramDir, true);
ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs; ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;

Some files were not shown because too many files have changed in this diff Show More