~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/ConstantScoreQueryBuilder.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.xmlparser.builders;
2
 
 
3
 
import org.apache.lucene.search.ConstantScoreQuery;
4
 
import org.apache.lucene.search.Query;
5
 
import org.apache.lucene.xmlparser.DOMUtils;
6
 
import org.apache.lucene.xmlparser.FilterBuilderFactory;
7
 
import org.apache.lucene.xmlparser.ParserException;
8
 
import org.apache.lucene.xmlparser.QueryBuilder;
9
 
import org.w3c.dom.Element;
10
 
/**
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
17
 
 *
18
 
 *     http://www.apache.org/licenses/LICENSE-2.0
19
 
 *
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.
25
 
 */
26
 
 
27
 
/**
28
 
 * 
29
 
 */
30
 
public class ConstantScoreQueryBuilder implements QueryBuilder
31
 
{
32
 
        private FilterBuilderFactory filterFactory;
33
 
 
34
 
        public ConstantScoreQueryBuilder(FilterBuilderFactory filterFactory)
35
 
        {
36
 
                this.filterFactory=filterFactory;
37
 
        }
38
 
 
39
 
        public Query getQuery(Element e) throws ParserException
40
 
        {
41
 
                Element filterElem=DOMUtils.getFirstChildOrFail(e);
42
 
                Query q=new ConstantScoreQuery(filterFactory.getFilter(filterElem));
43
 
 
44
 
                q.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
45
 
 
46
 
                return q;
47
 
                
48
 
        }
49
 
 
50
 
}