1   /*
2    * Copyright (c) 2003 by Atlassian Software Systems Pty. Ltd.
3    * All rights reserved.
4    */
5   package com.atlassian.bonnie;
6   
7   import org.apache.lucene.search.Filter;
8   import org.apache.lucene.search.Query;
9   import org.apache.lucene.search.Sort;
10  
11  import java.util.List;
12  import java.util.Set;
13  
14  /**
15   * Searches through all objects that have been indexed using a free text query.
16   * To index an object allowing it to show up in the search, use Indexer
17   * @see com.atlassian.bonnie.Searcher
18   *
19   * @author   Armond Avanes (armond555@yahoo.com)
20   */
21  public interface Searcher
22  {
23      //~ Methods --------------------------------------------------------------------------------------------------------
24  
25      /**
26       * Performs the search operation and returns a List of found items.
27       */
28      public List search(Query query);
29  
30      public List search(Query myquery, Sort sort);
31  
32      /**
33       * Performs a search over multiple fields
34       * @param searchFields a sting array of fields to search accross
35       * @param query the qury to execute
36       * @return a list of Hit results
37       */
38      public Query buildStandardQuery(String[] searchFields, String query);
39  
40      public Query buildStandardQuery(String field, String query);
41  
42      /**
43       * Search an index and return not only the item handles, but also pull arbitrary fields from the document and return them too.
44       * <p/>
45       * Extracting fields from all documents could be expensive and potentially unnecessary, so the startIndex and numItems parameters
46       * allow you to control where the extraction will start from, and how many items it will continue for.
47       * <p/>
48       *
49       * @param myquery The query to run
50       * @param fieldsToExtract A set of field names which will be extracted from the document and returned - if the fields are null, or the set is empty, BaseDocumentBuilder.FieldName.HANDLE_FIELD_NAME will be used.
51       * @param startIndex The index to start extracting content from, or 0 for the start of the list
52       * @param numItems The number of items to be extracted in total, or Integer.MAX_VALUE for all items
53       * @return A list containing maps of the fields you wish to extract. For results outside of the startIndex/numItems range, this list will contain null values.
54       */
55      List searchForFields(Query myquery, Set fieldsToExtract, int startIndex, int numItems);
56      List searchForFields(Query myquery, Set fieldsToExtract, int startIndex, int numItems, Filter filter, int[] filteredcount);
57      List searchForFields(Query myquery, Set fieldsToExtract, int startIndex, int numItems, Filter filter, Sort sorter, int[] filteredcount);
58  
59      List getAllFieldValues(String fieldName);
60  
61      /**
62       * Run a search, but just give me back the result as a #.
63       */
64      int searchCount(Query query);
65  
66      int searchCount(Query query, Filter filter);
67  
68      String explain(Query query, int docid);
69  
70      Query rewrite(Query query);
71  }