Package org.opengrok.indexer.search
Class SearchEngine
java.lang.Object
org.opengrok.indexer.search.SearchEngine
This is an encapsulation of the details on how to search in the index database.
This is used for searching via the REST API.
- Author:
- Trond Norbye 2005, Lubos Kosco - upgrade to lucene 3.x, 4.x, 5.x
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.lucene.util.Version
Version of Lucene index common for the whole application.static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Free resources associated with this instance.org.apache.lucene.document.Document
doc
(int docId) Gets the document of the specifieddocId
fromsearch(...)
if it was called.Getter for property definition.getFile()
Getter for property file.Getter for property freetext.Getter for property history.getQuery()
Gets the instance fromsearch(...)
if it was called.Gets the builder fromsearch(...)
if it was called.org.apache.lucene.search.Query
Gets the instance fromsearch(...)
if it was called.org.apache.lucene.search.IndexSearcher
Gets the searcher fromsearch(...)
if it was called.Getter for property symbol.getType()
Getter for property type.boolean
void
Get results , if no search was started before, no results are returned.org.apache.lucene.search.ScoreDoc[]
Gets the queried score docs fromsearch(...)
if it was called.int
search()
Execute a search without authorization.int
Execute a search aware of current request, limited to specific project names.void
setDefinition
(String definition) Setter for property definition.void
Setter for property file.void
setFreetext
(String freetext) Setter for property freetext.void
setHistory
(String history) Setter for property history.void
Setter for property symbol.void
Setter for property type.
-
Field Details
-
LUCENE_VERSION
public static final org.apache.lucene.util.Version LUCENE_VERSIONVersion of Lucene index common for the whole application. -
LUCENE_VERSION_HELP
-
-
Constructor Details
-
SearchEngine
public SearchEngine()Creates a new instance of SearchEngine.
-
-
Method Details
-
isValidQuery
public boolean isValidQuery() -
getQuery
Gets the instance fromsearch(...)
if it was called.- Returns:
- defined instance or
null
-
getQueryObject
public org.apache.lucene.search.Query getQueryObject()Gets the instance fromsearch(...)
if it was called.- Returns:
- defined instance or
null
-
getQueryBuilder
Gets the builder fromsearch(...)
if it was called.(Modifying the builder will have no effect on this
SearchEngine
.)- Returns:
- defined instance or
null
-
getSearcher
public org.apache.lucene.search.IndexSearcher getSearcher()Gets the searcher fromsearch(...)
if it was called.- Returns:
- defined instance or
null
-
search
Execute a search aware of current request, limited to specific project names. This filters out all projects which are not allowed for the current request. Before calling this function, you must set the appropriate search criteria with the set-functions. Note that this search will return the first cachePages of hitsPerPage, for more you need to call more. Call to search() must be eventually followed by call to destroy() so that IndexSearcher objects are properly freed.- Parameters:
projects
- projects to search- Returns:
- The number of hits
-
search
public int search()Execute a search without authorization. Before calling this function, you must set the appropriate search criteria with the set-functions. Note that this search will return the first cachePages of hitsPerPage, for more you need to call more. Call to search() must be eventually followed by call to destroy() so that IndexSearcher objects are properly freed.- Returns:
- The number of hits
-
scoreDocs
public org.apache.lucene.search.ScoreDoc[] scoreDocs()Gets the queried score docs fromsearch(...)
if it was called.- Returns:
- a defined instance if a query succeeded, or
null
-
doc
Gets the document of the specifieddocId
fromsearch(...)
if it was called.- Parameters:
docId
- document ID- Returns:
- a defined instance if a query succeeded
- Throws:
IOException
- if an error occurs obtaining the Lucene document by ID
-
results
Get results , if no search was started before, no results are returned. This method will requery ifend
is more than first query from search, hence performance hit applies, if you want results in later pages than number of cachePages.end
has to be bigger thanstart
!- Parameters:
start
- start of the hit listend
- end of the hit listret
- list of results from start to end or null/empty if no search was started
-
destroy
public void destroy()Free resources associated with this instance. -
getDefinition
Getter for property definition.- Returns:
- Value of property definition.
-
setDefinition
Setter for property definition.- Parameters:
definition
- New value of property definition.
-
getFile
Getter for property file.- Returns:
- Value of property file.
-
setFile
Setter for property file.- Parameters:
file
- New value of property file.
-
getFreetext
Getter for property freetext.- Returns:
- Value of property freetext.
-
setFreetext
Setter for property freetext.- Parameters:
freetext
- New value of property freetext.
-
getHistory
Getter for property history.- Returns:
- Value of property history.
-
setHistory
Setter for property history.- Parameters:
history
- New value of property history.
-
getSymbol
Getter for property symbol.- Returns:
- Value of property symbol.
-
setSymbol
Setter for property symbol.- Parameters:
symbol
- New value of property symbol.
-
getType
Getter for property type.- Returns:
- Value of property type.
-
setType
Setter for property type.- Parameters:
fileType
- New value of property type.
-