1 package org.apache.lucene.xmlparser;
3 import org.apache.lucene.analysis.Analyzer;
4 import org.apache.lucene.queryParser.QueryParser;
5 import org.apache.lucene.xmlparser.builders.BooleanFilterBuilder;
6 import org.apache.lucene.xmlparser.builders.BoostingQueryBuilder;
7 import org.apache.lucene.xmlparser.builders.DuplicateFilterBuilder;
8 import org.apache.lucene.xmlparser.builders.FuzzyLikeThisQueryBuilder;
9 import org.apache.lucene.xmlparser.builders.LikeThisQueryBuilder;
10 import org.apache.lucene.xmlparser.builders.TermsFilterBuilder;
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed with
14 * this work for additional information regarding copyright ownership.
15 * The ASF licenses this file to You under the Apache License, Version 2.0
16 * (the "License"); you may not use this file except in compliance with
17 * the License. You may obtain a copy of the License at
19 * http://www.apache.org/licenses/LICENSE-2.0
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an "AS IS" BASIS,
23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
31 public class CorePlusExtensionsParser extends CoreParser
35 * Construct an XML parser that uses a single instance QueryParser for handling
36 * UserQuery tags - all parse operations are synchronized on this parser
38 * @param parser A QueryParser which will be synchronized on during parse calls.
40 public CorePlusExtensionsParser(Analyzer analyzer, QueryParser parser)
42 this(null,analyzer, parser);
45 * Constructs an XML parser that creates a QueryParser for each UserQuery request.
46 * @param defaultField The default field name used by QueryParsers constructed for UserQuery tags
49 public CorePlusExtensionsParser(String defaultField,Analyzer analyzer)
51 this(defaultField,analyzer, null);
54 private CorePlusExtensionsParser(String defaultField,Analyzer analyzer, QueryParser parser)
56 super(defaultField,analyzer, parser);
57 filterFactory.addBuilder("TermsFilter",new TermsFilterBuilder(analyzer));
58 filterFactory.addBuilder("BooleanFilter",new BooleanFilterBuilder(filterFactory));
59 filterFactory.addBuilder("DuplicateFilter",new DuplicateFilterBuilder());
60 String fields[]={"contents"};
61 queryFactory.addBuilder("LikeThisQuery",new LikeThisQueryBuilder(analyzer,fields));
62 queryFactory.addBuilder("BoostingQuery", new BoostingQueryBuilder(queryFactory));
63 queryFactory.addBuilder("FuzzyLikeThisQuery", new FuzzyLikeThisQueryBuilder(analyzer));