View Javadoc

1   /* Copyright (c) 2008 Sascha Kohlmann
2    *
3    * This program is free software: you can redistribute it and/or modify
4    * it under the terms of the GNU Affero General Public License as published by
5    * the Free Software Foundation, either version 3 of the License, or
6    * (at your option) any later version.
7    *
8    * This program is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   * GNU Affero General Public License for more details.
12   *
13   * You should have received a copy of the GNU Affero General Public License
14   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15   */
16  package net.sf.eos.search;
17  
18  import java.util.List;
19  
20  import net.sf.eos.EosException;
21  import net.sf.eos.config.Configurable;
22  
23  /**
24   * A query is always constructed by the {@link EosLookup} instance and supports
25   * simple lookups in an entity oriented search index.
26   * 
27   * <p>The query is very simple. At this time an entity oriented search system
28   * doesn't need sophisticated queries.
29   *
30   * @author Sascha Kohlmann
31   */
32  public interface EosQuery extends Configurable {
33  
34      /**
35       * Adds a phrase to lookup with the boolean {@literal and} operation.
36       * @param phrase the phrase to lookup
37       * @return this instance
38       * @throws EosException if an error occurs
39       */
40      EosQuery and(final String phrase) throws EosException;
41  
42      /**
43       * Adds a phrase to lookup with the boolean {@literal or} operation.
44       * @param phrase the phrase to lookup
45       * @return this instance
46       * @throws EosException if an error occurs
47       */
48      EosQuery or(final String phrase) throws EosException;
49  
50      /**
51       * Adds a phrase not to lookup with the boolean {@literal and} operation.
52       * @param phrase the phrase to lookup
53       * @return this instance
54       * @throws EosException if an error occurs
55       */
56      EosQuery andNot(final String phrase) throws EosException;
57  
58      /**
59       * Adds a meta entry for a special field to lookup with the boolean
60       * {@literal and} operation.
61       * @param fieldName the meta field name to lookup
62       * @param value the meta value to lookup
63       * @return this instance
64       * @throws EosException if an error occurs
65       */
66      EosQuery andMeta(final String fieldName, final String value) throws EosException;
67  
68      /**
69       * Adds a meta entry for a special field to not lookup with the boolean
70       * {@literal and} operation.
71       * @param fieldName the meta field name to lookup
72       * @param value the meta value to lookup
73       * @return this instance
74       * @throws EosException if an error occurs
75       */
76      EosQuery andNotMeta(final String fieldName, final String value) throws EosException;
77  
78      /**
79       * Adds a meta entry for a special field to lookup with the boolean
80       * {@literal or} operation.
81       * @param fieldName the meta field name to lookup
82       * @param value the meta value to lookup
83       * @return this instance
84       * @throws EosException if an error occurs
85       */
86      EosQuery orMeta(final String fieldName, final String value) throws EosException;
87  
88      /**
89       * Adds a meta entry for a special field to lookup with the boolean
90       * {@literal and} operation. The two value parameters spans a range between
91       * the lower bound value and the upper bound value.
92       * @param fieldName the meta field name to lookup
93       * @param lowerBoundValue the meta lower bound value to lookup
94       * @param upperBoundValue the meta upper bound value to lookup
95       * @return this instance
96       * @throws EosException if an error occurs
97       */
98      EosQuery andMetaRange(final String fieldName,
99                            final String lowerBoundValue,
100                           final String upperBoundValue) throws EosException;
101 
102     /**
103      * Adds a meta entry for a special field to lookup with the boolean
104      * {@literal or} operation. The two value parameters spans a range between
105      * the lower bound value and the upper bound value.
106      * @param fieldName the meta field name to lookup
107      * @param lowerBoundValue the meta lower bound value to lookup
108      * @param upperBoundValue the meta upper bound value to lookup
109      * @return this instance
110      * @throws EosException if an error occurs
111      */
112     EosQuery orMetaRange(final String fieldName,
113                          final String lowerBoundValue,
114                          final String upperBoundValue) throws EosException;
115 
116     /**
117      * Creates the executable query.
118      * @return the executable query
119      * @throws EosException if an error occurs
120      */
121     List<LookupEntry> execute() throws EosException;
122 }