1
package org.apache.lucene.xmlparser.builders;
3
import org.apache.lucene.index.Term;
4
import org.apache.lucene.search.Query;
5
import org.apache.lucene.search.TermQuery;
6
import org.apache.lucene.xmlparser.DOMUtils;
7
import org.apache.lucene.xmlparser.ParserException;
8
import org.apache.lucene.xmlparser.QueryBuilder;
9
import org.w3c.dom.Element;
11
* Licensed to the Apache Software Foundation (ASF) under one or more
12
* contributor license agreements. See the NOTICE file distributed with
13
* this work for additional information regarding copyright ownership.
14
* The ASF licenses this file to You under the Apache License, Version 2.0
15
* (the "License"); you may not use this file except in compliance with
16
* the License. You may obtain a copy of the License at
18
* http://www.apache.org/licenses/LICENSE-2.0
20
* Unless required by applicable law or agreed to in writing, software
21
* distributed under the License is distributed on an "AS IS" BASIS,
22
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
* See the License for the specific language governing permissions and
24
* limitations under the License.
30
public class TermQueryBuilder implements QueryBuilder {
32
public Query getQuery(Element e) throws ParserException {
34
String field=DOMUtils.getAttributeWithInheritanceOrFail(e,"fieldName");
35
String value=DOMUtils.getNonBlankTextOrFail(e);
36
TermQuery tq = new TermQuery(new Term(field,value));
37
tq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));