add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / xml-query-parser / src / demo / WebContent / WEB-INF / query.xsl
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!--
3  Licensed to the Apache Software Foundation (ASF) under one or more
4  contributor license agreements.  See the NOTICE file distributed with
5  this work for additional information regarding copyright ownership.
6  The ASF licenses this file to You under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with
8  the License.  You may obtain a copy of the License at
9
10      http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17 -->
18 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
19 <xsl:template match="/Document">
20 <BooleanQuery>
21         <!-- Clause if user selects a preference for type of job - apply choice of 
22              permanent/contract filter and cache -->
23         <xsl:if test="type">
24             <Clause occurs="must">
25                 <ConstantScoreQuery>
26                    <CachedFilter>
27                         <TermsFilter fieldName="type"><xsl:value-of select="type"/></TermsFilter>
28                    </CachedFilter>
29                  </ConstantScoreQuery>
30            </Clause>
31         </xsl:if>
32                 
33         <!-- Use standard Lucene query parser for any job description input -->
34         <xsl:if test="description">
35                 <Clause occurs="must">
36                         <UserQuery fieldName="description"><xsl:value-of select="description"/></UserQuery>
37                 </Clause>
38         </xsl:if>      
39         
40         <!-- If any of the location fields are set OR them ALL in a Boolean filter and cache individual filters -->
41         <xsl:if test="South|North|East|West">
42                 <Clause occurs="must">
43                         <ConstantScoreQuery>
44                                 <BooleanFilter>
45                                         <xsl:for-each select="South|North|East|West">
46                                         <Clause occurs="should">
47                                                 <CachedFilter>
48                                                         <TermsFilter fieldName="location"><xsl:value-of select="name()"/></TermsFilter>
49                                                 </CachedFilter>
50                                         </Clause>
51                                         </xsl:for-each>                                 
52                                 </BooleanFilter>
53                         </ConstantScoreQuery>
54                 </Clause>
55         </xsl:if>       
56         
57         <!-- Use XSL functions to split and zero pad salary range value -->
58         <xsl:if test="salaryRange">
59                 <Clause occurs="must">
60                         <ConstantScoreQuery>
61                                 <RangeFilter fieldName="salary" >
62                                         <xsl:attribute name="lowerTerm">
63                                                 <xsl:value-of select='format-number( substring-before(salaryRange,"-"), "000" )' />
64                                         </xsl:attribute> 
65                                         <xsl:attribute name="upperTerm">
66                                                 <xsl:value-of select='format-number( substring-after(salaryRange,"-"), "000" )' />
67                                         </xsl:attribute> 
68                                 </RangeFilter>
69                         </ConstantScoreQuery>
70                 </Clause>
71         </xsl:if>       
72 </BooleanQuery>
73 </xsl:template>
74 </xsl:stylesheet>