Project

General

Profile

Properties, Methods and parameters

There is only a limited set of methods available, but the amount of parameters you can pass in allows for a great number of customization.
The 3 main methods are: and you also have 3 other methods: and 4 properties:

query()

This method queries the Solr index, given a parameter object which holds the query parameters.
The query whole method signature is:
JSObject query(JSObject parameters)

It returns a JavaScript object which holds the Solr result.
parameters is a regular JavaScript object, that will take as properties the content of the query.

See the Solr Wiki for in-depth information about the parameters you can use to query, similar to the parameters below, and what they do.

Available properties for the parameters JSObject:

  • core: (String) that sets the core to use for that query (in case of multi index Solr core installation)
  • query: (String) the main query (the only required property)
  • queryType: (String) maps to the query handlers defined in Solr, default is "standard"
  • start: (Integer) used for pagination, the starting row returned, default is 0
  • rows: (Integer) used for pagination, the maximum number of rows returned, default is -1 = all (beware that this might be big depending on the size of your index!)
  • filters: (String (can be delimited by ',' ';' or spaces) | String[]) filters the query, uses the same queryType query syntax as the query itself
  • fields: (String (can be delimited by ',' ';' or spaces) | String[]) defines the fields to be returned, default is '*' = all
  • sortBy: (String (can be delimited by ',' ';' or spaces) | String[]) sorts the results, uses a syntax similar to SQL 'sort by'
  • hiliting: (Boolean) set whether hilighlighting information will be returned, default is false
  • hiliteFields: (String (can be delimited by ',' ';' or spaces) | String[]) the fields to returned as highlighted snippets
  • hiliteFragSize: (Integer) the maximum size of the highlighted snippets returned
  • hiliteRequireFieldMatch: (Boolean) set whether the highlighted parts of the snippets will be closely matching the query
  • hiliteSnippets: (Integer) the maximum number of snippets to return (in case of multi-valued fields there can be many), default is 1
  • hiliteSimplePre: (String) the tag to use in front of each matched snippet, default is '<em>'
  • hiliteSimplePost: (String) the tag to use after each matched snippet, default is '</em>'
  • hiliteMaxAnalyzedChars: (Integer) the character limit to look for highlights, default is 51200 characters
  • facet: (Boolean) whether to use faceting, default is false
  • facets: (String (can be delimited by ',' ';' or spaces) | String[]) defines the facets to use, using the queryType query syntax
  • facetLimit: (Integer) the maximum number of facets, default is -1 = Solr default (100?)
  • facetMinCount: (Integer) the minimum number of facets, default is 0 = none
  • facetMissing: (Boolean) the faceting will take into account the documents that have null for the criteria, default to false
  • facetSort: (String) the sort to apply on the facets
  • includeScore: (Boolean) adds the score of each document in the returned object, default to false
  • debug: (Boolean) whether to receive debug information about the query, default to false
  • extras: (Object) an optional object with key,value allowing to pass custom parameters to the query

Available properties of the returned JSObject:

  • responseHeader: (JSObject) the header contains a few properties about the completion of the query:
    • status: (Integer) 0 = no error, otherwise a Solr error code
    • QTime: (Integer) number of milliseconds the query took (for optimisation purpose)
    • params: (JSObject) contains the parameters used in the query
  • response: (JSObject) the main object containing the document fields
    • numFound: (Integer) the number of documents found
    • start: (Integer) the index of the first row returned
    • docs: (JSObject[]) the array of documents, each JSObject in that array will contain one property per fields (depends on the indexed fields and the one set by the 'fields' property of the query parameters
  • highlighting: (JSObject) if the 'hiliting' property was set to true in the query parameters, then this object will contain a property named from the id of each document
    • id: (JSObject) the key 'id' here will be the actual id of the document, and the value will be an object containing the snippets, with a key of each 'hiliteFields' provided in the query parameters
      • field (String[]) the key 'field' will be the actual field name as provided in the 'hiliteFields' property of the query parameters, the value will be an array of String[] from 0 to x, where x is the maximum number of snippets as set by the 'hiliteSnippets' property of the query parameters
  • debug: (JSObject) containing a few properties explaining the search made (useful for debug and performance tweaking of schema, index and queries of Solr)

remove()

This method removes a document from the Solr index (and optionally the file copied on the server).
The remove method signature is:
boolean remove(id, [newFileName])

Where id is the identifier of the object that was previously inserted in the Solr index (can be a unique String, UUID or Integer)
And newFileName is an optional parameter giving the name of the file to be removed from the server (the new name that was returned by the original submit to the Solr index).

The method will return true if the document was removed from the Solr index (and optionally removed from the server hard drive), false otherwise.

submit()

This method submit document(s) to the server for parsing, copying and insert/updating in the Solr index.
The submit method signature is:
SubmitResult submit(JSObject parameters)

I returns a SubmitResult JavaScript object holding the result of the process on the server side.
parameters is a regular JavaScript object, that will take a whole lot of properties representing the process to do on the server side.

Available properties for the parameters JSObject:

  • core: String that sets the core to use for that submit (in case of multi index Solr core installation)
  • defaultLogin: String used by default for URL retrieving when authentication is asked by the server (can be overriden by document)
  • defaultPassord: String used by default for URL retrieving when authentication is asked by the server (can be overriden by document)
  • callback: Function the callback function provided will be called for each document send, with a SubmitResult object
  • trimUnwantedSpaces: Boolean, if true, all double spaces will be trimmed from the parsed content (default = false)
  • replaceRules: JSObject or JSObject[] that will be used to perform further text processing on the parsed content
  • newPath: a path to use for the upload file or url. The final save path on the server will be: smartDocPlugin.saveToFolder + newPath + name, so newPath should always start with a '/' (an exception will be thrown if this is not the case).
    the JSObject needs to contain 2 properties:
    • pattern: String containing a Regexp pattern to be used to capture the text to be replaced
    • replacement: String that is used as replacement text (can be "")
  • accepted: String[] contains an array of file extensions that will be accepted, all other file extensions will be ignored and return an error of type SubmitResult.ERROR_FORMAT - if null or empty, any file will be accepted.
  • documents: - mandatory JSObject[] an array of documents to be processed.
    • id: - mandatory String, or Integer or UUID - unique identifier of the document to be processed,
      the JSObject need to contain at least 1 of the 2 following properties:
    • url: String of the URL where the server will be able to retrieve the document (protocol can be http, https, ftp)
    • file: String path of a file (client side path), or java.io.File, or JSFile (from the plugins.file) representing the file to be send to the server for processing.
    • login: String to be used for authentication - will override defaultLogin for this specific document
    • password: String to be used for authentication - will override defaultPassword for this specific document
    • trimUnwantedSpaces: Boolean, will override trimUnwantedSpaces for this specific document
    • newPath: the new path to use to save the document (overrides the parameters newPath)
    • newName: will override the renaming scheme, and rename the end file on the server using the provided name for this document
    • replaceRules: JSObject or JSObject[] that will be used to perform further text processing on the parsed content, will override replaceRules for this specific document
      the JSObject needs to contain 2 properties:
      • pattern: String containing a Regexp pattern to be used to capture the text to be replaced
      • replacement: String that is used as replacement text (can be "")
    • pdfPassword: Password used to open PDF protected file
    • extras: JSObject, each property/value pair in the extras JSObject will be added to the Solr update query field along with the document parsed content and metadata.

getFileURL()

This method returns a URL to retrieve a file from the server.
The getFileURL method signature is:
String getFileURL([path], newName, [mimeType])

path is optional, in case you specified a path when submitting, using the newPath parameter
newName is the new name of the file, as returned by the SubmitResult object (coming from a newName provided, the renaming scheme, or the original name)
mimeType is a mimeType in case you want to provide a mimeType to use (for example a file with an extension of .txt that you want to open as a CSV file would take a mimeType of "text/csv")
The method returns a URL as a String, suitable to use in a web client or using application.showURL(), the URL will be served by the plugin's internal servlet, with proper mime-type set in the header of the response depending on the type of the file (you can override this mimeType if needed using the optional third parameter)

stopProcess()

This method stops the current submit process (after the current file is processed on the server side).

getVersion()

This method returns the version of the plugin.
The getVersion method signature is:
String getVersion()

A convenience method to help debug/issue tracking, and your own version management.

useSolrServer

Set by the server plugin admin property "smartDocPlugin.useSolr", but you can override it per client session:
If true, the submit process will attempt to insert/update the Solr index, and the query process will query the Solr Server
If false, no attempt to use the Solr server will be done.

storeOnServer

Set by the server plugin admin property "smarDocPlugin.storeOnServer", but you can override it per client session:
If true, the files/url contents submitted will be stored on the server at the location set by the server plugin admin property "smartDocPlugin.saveToFolder"
If false, temporary files will still be used at this same location for the parsing process, but will not be kept.

serverFolder

Set by the server plugin admin property "smartDocPlugin.saveToFolder", but you can override it per client session
This is the location (absolute path of a folder from the server side) where the documents will be saved, default is a "smartdoc" folder located in application_server/server/webapps/ROOT

solrServerURL

Set by the server plugin admin property "smartDocPlugin.solrServerURL", but you can override it per client session
This is the URL of the Solr instance used to index/query, if set to null, no attempt will be made to update/query the index.