DocAPI.v1.Search
hidden class DocAPI.v1.Search extends %Library.RegisteredObject
This class, which supports DocAPI.v1.REST, provides an API to perform searches and return matches from the DocBook database. The methods in this class can return either an instance of %Library.DynamicObject or a JSON string. The returned object has the following properties:- queryParm - an object that contains the query parameters.
This object can have the following properties:
- searchPhrase - the string of characters to search for.
- searchType - specifies the type of query used in the SQL part of the search. Options are 1 (stemming), 2 (SQL contains operator, case-insensitive), or 3 (SQL contains operator, case-sensitive).
- operator - "AND" or "OR"
- product - the name of the product used to restrict the search. This property is omitted if no such restriction was used. Note that currently only one product filter can be applied.
- book - the code of the book or article used to restrict the search. This property is omitted if no such restriction was used. Note that currently only one book/article filter can be applied.
- tags - the tag used to restrict the search. This property is omitted if no such restriction was used. Note that currently only one search tag can be used.
- foundInIndex - an object that contains information about hits found within the index global.
This object can have the following properties:
- resultCount - number of times the search phrase was found in the index global.
- hits - an array of objects, each of which represents a hit found in the index global. Each of these objects has the following properties: dbtype (the DocBook type of the hit), URL (the key of the hit), text (the text of the hit), and locator (see below for information on locator). The hits property is omitted if there are no hits.
- foundInSQL - an object that contains information about hits found via an SQL query.
This object can have the following properties:
- resultCount - number of hits that were found (note that the query is limited to the top 1000, so this will always be less than that).
- topicCount - number of topics in which these hits were found. A topic is a chapter, appendix, or other parallel unit that is displayed as a page.
- pageNumber - an integer, indicating which page of *results* are contained here. We return only 20 topics in any page of results.
- topics - an array of objects, each of which represents a topic in which results were found.
Each of these objects has the following properties:
- key - indicates the DocBookId of the topic.
- locator - an array of objects, each of which corresponds to a higher heading level (for the topic we found). This array goes down to the sect3 level (if applicable). The first item in the array identifies the book or article. The second item identifies the chapter, appendix, or other unit at that level. The next item identifies the heading level below that, etc. Each object in this array has two properties: key (the DocBookId of that item) and title.
- hits - an array of objects, each of which represents a hit within this topic. In this array, each object has the properties dbtype (the DocBook type of the hit), URL (the key of the hit), and text (the text of the hit).
- query - the actual SQL query that was used for this portion of the search.
- searchTime - the time spent performing this search, in seconds.
Method Inventory
- CacheIt()
- CacheKEYs()
- GetFromIndex()
- GetResults()
- GetSQLResultsFromCache()
- HaveMatchingTag()
- MatchAllParms()
- ProcessIndex()
- RunQueryForProcessIndex()
- StartsWith()
Parameters
parameter CACHEAGEINDAYS = 14;
parameter DEFAULTOPERATOR = AND;
parameter DEFAULTRANK = 10000;
parameter DEFAULTSEARCHTYPE = 2;
parameter TOPICSPERPAGE = 20;
Methods
This method is responsible for putting the results into order by rank
(in the ppg ^||topicsbyorder).
classmethod GetFromIndex(searchKey As %String = "") as %Library.DynamicObject
See if the given phrase is in the index global (^DocBook.Index).
This method returns a %Library.DynamicObject that contains the results, if any.
This object can have the following properties:
- resultCount - number of times the search phrase was found in the index global.
- hits - an array of objects, each of which represents a hit found in the index global. Each of these objects has the following properties: type (the DocBook type of the hit), key (the DocBook ID of the hit), URL (uses the key of the hit), text (the text of the hit), and locator (see elsewhere for information on locator). The hits property is omitted if there are no hits.
classmethod GetResults(tPhrase="the", tProduct="", tBookId="", tTags="", tSearchType=..#DEFAULTSEARCHTYPE, tOperator=..#DEFAULTOPERATOR, pageNumber As %Integer = 1) as %Library.DynamicObject
This is the method that the REST API will call.
classmethod GetSQLResultsFromCache(tSearchKey As %String = "", pageNumber As %Integer = 1) as %Library.DynamicObject
Returns an object that contains information about hits found via an SQL query.
This object can have the following properties:
searchTime - the time spent performing this search, in seconds.
- resultCount - number of hits that were found (note that the query is limited to the top 1000, so this will always be less than that).
- topicCount - number of topics in which these hits were found. A topic is a chapter, appendix, or other parallel unit that is displayed as a page.
- pageNumber - an integer, indicating which page of *results* are contained here. We return only 20 topics in any page of results.
- topics - an array of objects, each of which represents a topic in which results were found.
Each of these objects has the following properties:
- key - indicates the DocBookId of the topic.
- locator - an array of objects, each of which corresponds to a higher heading level (for the topic we found). This array goes down to the sect3 level (if applicable). The first item in the array identifies the book or article. The second item identifies the chapter, appendix, or other unit at that level. The next item identifies the heading level below that, etc. Each object in this array has two properties: key (the DocBookId of that item) and title.
- hits - an array of objects, each of which represents a hit within this topic. In this array, each object has the properties type (the DocBook type of the hit), URL (the key of the hit), and text (the text of the hit).
- query - the actual SQL query that was used for this portion of the search.
Returns true if the given block is tagged with the given tag.
classmethod MatchAllParms(blockid, queryProduct As %String = "", queryBook As %String = "", queryTag As %String = "")
Check to see if the given blockid matches the rest of the query parameters
classmethod ProcessIndex(searchKey As %String = "")
classmethod RunQueryForProcessIndex(blockid, pBookId, pProductId)
classmethod StartsWith(string As %String, fragment As %String, caseSensitive As %Boolean = 0) as %Boolean
Returns true if string starts with the given fragment.
Inherited Members
Inherited Methods
- %AddToSaveSet()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %IsModified()
- %New()
- %NormalizeObject()
- %ObjectModified()
- %OriginalNamespace()
- %PackageName()
- %RemoveFromSaveSet()
- %SerializeObject()
- %SetModified()
- %ValidateObject()