Class SolrMethods
- java.lang.Object
-
- io.toro.martini.SolrMethods
-
public final class SolrMethods extends Object
Provides one-liners for performing Solr operations. Included in this class are one-liners for getting the
SolrClientof a Solr core, executing query statements against a core, easily creating schemas out of models, and others.
-
-
Constructor Summary
Constructors Constructor Description SolrMethods(io.toro.martini.coder.development.SchemaWriter writer, io.toro.martini.solr.SolrClientProvider<io.toro.martini.solr.MartiniSolrClient> solrClientProvider, io.toro.martini.solr.SolrSearchServiceFactory solrSearchServiceFactory, io.toro.martini.solr.PackageSolrCoreConfigurer packageSolrCoreConfigurer)
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidaddCore(String coreName, String modelNamespace, String uniqueKey, String packageName)Configures a Solr core with the schema based on a data model.static voidcommit(String coreName, String packageName)Explicitly commits all pending documents to the specified Solr core.static voidcreateDataModelFromSolrSchema(String name, String schema, String packageName, String namespace, List<GloopModel> resources)Create a data model based on a Solr schema.static voidcreateSolrSchemaFromDataModel(String destination, String packageName, String modelNamespace, String uniqueKey)Create a Solr schema based on a data model.static GloopModeldeleteAll(String coreName, String packageName, boolean commit)Deletes all documents from the specified Solr core by issuing a delete-by-query using the wildcard query*:*.static GloopModeldeleteById(String coreName, String packageName, List<String> ids)Delete Solr documents by ID.static GloopModeldeleteByQuery(String coreName, String packageName, String query)Delete Solr documents by query.static UpdateResponsedeleteByQueryString(String coreName, String packageName, String query)Delete Solr documents by query.static GloopModelfieldStatisticsSearch(String coreName, String packageName, String fieldName, List<GloopModel> solrParams)Generate statistics for a certain field.static io.toro.martini.solr.StatsfieldStatisticsSearch(String coreName, String packageName, String fieldName, Map<String,Collection<String>> solrParams)Generate statistics for a certain field.static GloopModelfieldValueFacetSearch(String coreName, String packageName, String fieldName, List<GloopModel> solrParams)Perform a faceted search for a specific field.static io.toro.martini.solr.FacetfieldValueFacetSearch(String coreName, String packageName, String fieldName, Map<String,Collection<String>> solrParams)Perform a faceted search for a specific field.static voidgloopModelToSolrSchema(String destination, String packageName, String modelNamespace)Deprecated.static voidgloopModelToSolrSchema(String destination, String packageName, String modelNamespace, String uniqueKey)Deprecated.static GloopCursorinsertMany(String coreName, String packageName, String commitMode, boolean closeClient, int batchSize, GloopExecutionContext context)Deprecated.static GloopCursorinsertMany(String coreName, String packageName, String commitMode, boolean closeClient, GloopExecutionContext context)Deprecated.static GloopModelmultiFieldStatisticsSearch(String coreName, String packageName, List<GloopModel> solrParams)Generate statistics for one or more fields.static List<io.toro.martini.solr.Stats>multiFieldStatisticsSearch(String coreName, String packageName, Map<String,Collection<String>> solrParams)Generate statistics for one or more fields.static GloopModelmultiFieldValueFacetSearch(String coreName, String packageName, List<GloopModel> solrParams)Perform a faceted search for a specific set of fields.static List<io.toro.martini.solr.Facet>multiFieldValueFacetSearch(String coreName, String packageName, Map<String,Collection<String>> solrParams)Perform a faceted search for a specific set of fields.static GloopModelmultiPivotFacetSearch(String coreName, String packageName, List<GloopModel> solrParams)Perform a multi pivot faceted search.static List<io.toro.martini.solr.PivotFacet>multiPivotFacetSearch(String coreName, String packageName, Map<String,Collection<String>> solrParams)Perform a multi pivot faceted search.static GloopCursoropenDocumentOutputCursor(String coreName, String packageName, String commitMode, boolean closeClient, int batchSize, GloopExecutionContext context)Opens a cursor for streaming Solr document output, document by document, without accumulating the full documents in memory.static GloopModelpivotFacetSearch(String coreName, String packageName, String fieldName, List<GloopModel> solrParams)Perform a pivot faceted search for a specific field.static io.toro.martini.solr.PivotFacetpivotFacetSearch(String coreName, String packageName, String fieldName, Map<String,Collection<String>> solrParams)Perform a pivot faceted search for a specific field.static GloopModelquery(String coreName, String packageName, List<GloopModel> solrParams)Query a Solr core.static QueryResponsequery(String coreName, String packageName, Map<String,String> solrParams)Query a Solr core.static QueryResponsequeryByMultiMap(String coreName, String packageName, Map<String,String[]> solrParams)Query a Solr core.static GloopModelrangeFacetSearch(String coreName, String packageName, String fieldName, List<GloopModel> solrParams)Perform a range faceted search for a specific field.static <B,G>
io.toro.martini.solr.RangeFacet<B,G>rangeFacetSearch(String coreName, String packageName, String fieldName, Map<String,Collection<String>> solrParams)Perform a range faceted search for a specific field.static voidreloadCore(String coreName, String packageName)Reloads the specified Solr core, applying any configuration changes made since it was last loaded.static voidremoveCore(String coreName, String packageName, boolean removeFiles)Removes an existing Solr core from a Martini package.static GloopModelsearchCore(String query, String coreName, String packageName, String sortField, String sortType, List<String> fields, int pageSize, int page)Search a Solr core.static io.toro.martini.solr.MartiniSolrClientsolr(String coreName)Get theSolrClientof a named Solr core, belonging to the package in the current context.static io.toro.martini.solr.MartiniSolrClientsolr(String coreName, GloopExecutionContext context)Get theSolrClientof a named Solr core, belonging to the package in the current context.static voidsolrSchemaToGloopModel(String name, String schema, String packageName, String namespace, List<GloopModel> resources)Deprecated.static voidsolrSchemaToGloopModel(String name, String schema, String packageName, String namespace, Map<String,String> resources)Deprecated.static GloopModelwriteDataModelToIndex(String coreName, String packageName, GloopModel dataModel)Index a document.static GloopModelwriteToIndex(String coreName, String packageName, GloopModel gloopModel)Deprecated.static UpdateResponsewriteToIndex(String coreName, String packageName, Object bean)Index a document.
-
-
-
Constructor Detail
-
SolrMethods
@Autowired SolrMethods(io.toro.martini.coder.development.SchemaWriter writer, io.toro.martini.solr.SolrClientProvider<io.toro.martini.solr.MartiniSolrClient> solrClientProvider, io.toro.martini.solr.SolrSearchServiceFactory solrSearchServiceFactory, io.toro.martini.solr.PackageSolrCoreConfigurer packageSolrCoreConfigurer)
-
-
Method Detail
-
deleteById
@GloopObjectParameter("output{\nupdateResponse#io.toro.martini.solr.UpdateResponse{\n }\n}") public static GloopModel deleteById(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowNull=false) List<String> ids) throws SolrServerException, IOException
Delete Solr documents by ID.- Parameters:
coreName- the name of the Solr core where the document belongspackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedids- the IDs of all Solr documents to be deleted- Returns:
- the response of the Solr server to the delete operation
- Throws:
SolrServerException- if there is an error on the serverIOException- if there is a low-level I/O error- Since:
- 1.0
-
deleteByQueryString
public static UpdateResponse deleteByQueryString(String coreName, String packageName, String query) throws SolrServerException, IOException
Delete Solr documents by query.- Parameters:
coreName- the name of the Solr core where the document belongspackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedquery- query selecting which Solr documents to delete- Throws:
SolrServerException- if there is an error on the serverIOException- if there is a low-level I/O error- Since:
- 1.0
-
deleteByQuery
@GloopObjectParameter("output{\nupdateResponse#io.toro.martini.solr.UpdateResponse{\n }\n}") public static GloopModel deleteByQuery(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowNull=false) String query) throws SolrServerException, IOException
Delete Solr documents by query.- Parameters:
coreName- the name of the Solr core where the document belongspackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedquery- query selecting which Solr documents to delete- Returns:
- the response of the Solr server to the delete operation
- Throws:
SolrServerException- if there is an error on the serverIOException- if there is a low-level I/O error- Since:
- 1.0
-
deleteAll
@GloopObjectParameter("output{\nupdateResponse#io.toro.martini.solr.UpdateResponse{\n }\n}") public static GloopModel deleteAll(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(defaultValue="true") boolean commit) throws SolrServerException, IOException
Deletes all documents from the specified Solr core by issuing a delete-by-query using the wildcard query*:*.- Parameters:
coreName- the name of the Solr core to clearpackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the workflow or service is invokedcommit- iftrue, immediately commits the deletion so the index is empty and queryable at once; iffalse, the deletion is buffered until the next commit- Returns:
- the response of the Solr server to the delete operation
- Throws:
SolrServerExceptionIOException
-
createSolrSchemaFromDataModel
public static void createSolrSchemaFromDataModel(@GloopParameter(allowNull=false) String destination, String packageName, @GloopParameter(allowNull=false) String modelNamespace, @GloopParameter(defaultValue="id") String uniqueKey) throws IOException
Create a Solr schema based on a data model.- Parameters:
destination- the destination directory of the to-be-generated Solr schemapackageName- the name of the package where the data model resides; if empty, this will assume the name of the package where the workflow or service is invokedmodelNamespace- the namespace of the model to be used as the basis of the Solr schemauniqueKey- the unique key of the Solr schema; default is id- Throws:
IOException- if the Solr schema cannot be created or written to the specified destination- Since:
- 2.8.0
-
gloopModelToSolrSchema
@Deprecated(since="2.8.0") public static void gloopModelToSolrSchema(@GloopParameter(allowNull=false) String destination, String packageName, @GloopParameter(allowNull=false) String modelNamespace) throws IOException
Deprecated.Create a Solr schema based on a Gloop model.- Parameters:
destination- the destination directory of the to-be-generated Solr schemapackageName- the name of the package where the Gloop model resides if empty, this will assume the name of the package where the service is invokedmodelNamespace- the namespace of the model to be used as the basis of the Solr schema- Throws:
IOException- Since:
- 1.0
-
gloopModelToSolrSchema
@Deprecated(since="2.8.0") public static void gloopModelToSolrSchema(@GloopParameter(allowNull=false) String destination, String packageName, @GloopParameter(allowNull=false) String modelNamespace, @GloopParameter(defaultValue="id") String uniqueKey) throws IOException
Deprecated.Create a Solr schema based on a Gloop model.- Parameters:
destination- the destination directory of the to-be-generated Solr schemapackageName- the name of the package where the Gloop model resides if empty, this will assume the name of the package where the service is invokedmodelNamespace- the namespace of the model to be used as the basis of the Solr schemauniqueKey- the unique key of the Solr schema- Throws:
IOException- Since:
- 1.1
-
addCore
public static void addCore(@GloopParameter(allowNull=false) String coreName, @GloopParameter(allowNull=false) String modelNamespace, @GloopParameter(defaultValue="id") String uniqueKey, String packageName) throws IOException
Configures a Solr core with the schema based on a data model. Adds the configured Solr core to the provided package name.- Parameters:
coreName- the name of the to-be-generate Solr coremodelNamespace- the namespace of the model to be used as the basis of the Solr schemauniqueKey- the unique key of the Solr schema; default is idpackageName- the name of the package where the Solr core will be added if empty, this will assume the name of the package where the service is invoked- Throws:
IOException- Since:
- 1.1
-
removeCore
public static void removeCore(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(defaultValue="false") boolean removeFiles)
Removes an existing Solr core from a Martini package.- Parameters:
coreName- the name of the existing Solr corepackageName- the name of the package where the Solr core resides if empty, this will assume the name of the package where the service is invokedremoveFiles- the flag that indicates whether to remove the core's configuration files; default isfalse- Since:
- 1.1
-
createDataModelFromSolrSchema
public static void createDataModelFromSolrSchema(@GloopParameter(allowNull=false) String name, @GloopParameter(allowNull=false) String schema, @GloopParameter(allowNull=false) String packageName, @GloopParameter(defaultValue="model") String namespace, @GloopObjectParameter("resources[]{\n resourceName\n resourceContent\n }") List<GloopModel> resources)
Create a data model based on a Solr schema. This one-liner allows you to provide external resources needed in order to parse the schema.
Consider the schema below:
This schema requires the external XML configuration fileenumConfig.xmlto identify the valid choices for thepriorityLevelfield. To satisfy this requirement, the caller must add an entry to theresourcesarray. The value would be the name of the file, which isenumConfig.xml, and the XML content of the file.- Parameters:
name- the name of the to-be-generated data modelschema- the content of the Solr schema which will be used as the basis of the data modelpackageName- the name of the package where the data model will residenamespace- the namespace of the to-be-generated data model; this dictates where the model will reside. Default is model.resources- an array of required resources (each indicating the filename and file content) needed to properly parse the Solr schema- Since:
- 2.8.0
-
solrSchemaToGloopModel
@Deprecated(since="2.8.0") public static void solrSchemaToGloopModel(String name, String schema, String packageName, String namespace, Map<String,String> resources)
Deprecated.Create a Gloop model based on a Solr schema. This one-liner allows you to provide external resources needed in order to parse the schema.
Consider the schema below:
This schema requires the external XML configuration fileenumConfig.xmlto identify the valid choices for thepriorityLevelfield. To satisfy this requirement, the caller must add an entry to theresourcesmap. The value would be the name of the file, which isenumConfig.xml, and the XML content of the file.- Parameters:
name- the name of the to-be-generated modelschema- the content of the Solr schema which will be used as the basis of the Gloop modelpackageName- the name of the package where the Gloop model will residenamespace- the namespace of the to-be-generated Gloop model; this dictates where the model will resideresources- a map of required resources (filename to file content) needed to properly parse the Solr schema- Since:
- 1.0
-
solrSchemaToGloopModel
@Deprecated(since="2.8.0") public static void solrSchemaToGloopModel(@GloopParameter(allowNull=false) String name, @GloopParameter(allowNull=false) String schema, @GloopParameter(allowNull=false) String packageName, @GloopParameter(allowNull=false,defaultValue="model") String namespace, @GloopParameter(allowExtraProperties=false) @GloopObjectParameter("resources[]{\n resourceName\n resourceContent\n}") List<GloopModel> resources)
Deprecated.Create a Gloop model based on a Solr schema. This one-liner allows you to provide external resources needed in order to parse the schema.
Consider the schema below:
This schema requires the external XML configuration fileenumConfig.xmlto identify the valid choices for thepriorityLevelfield. To satisfy this requirement, the caller must add an entry to theresourcesmap. The value would be the name of the file, which isenumConfig.xml, and the XML content of the file.- Parameters:
name- the name of the to-be-generated modelschema- the content of the Solr schema which will be used as the basis of the Gloop modelpackageName- the name of the package where the Gloop model will residenamespace- the namespace of the to-be-generated Gloop model; this dictates where the model will resideresources- an array of required resources (each indicating the filename and file content) needed to properly parse the Solr schema- Since:
- 1.0
-
writeDataModelToIndex
@GloopObjectParameter("output{\nupdateResponse#io.toro.martini.solr.UpdateResponse{\n }\n}") public static GloopModel writeDataModelToIndex(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowNull=false) GloopModel dataModel) throws SolrServerException, IOException
Index a document. This one-liner allows the caller to add a new document or update an existing one, depending on the provided arguments.
Solr will rely on the Solr core's configured schema to identify which properties of the model to index.
When updating a document, updates are partial. Only provided fields will be indexed. This one-liner also works with data models with
FieldModifierproperties.FieldModifierproperties mirror Solr's modifier argument forSolrInputDocuments.- Parameters:
coreName- the name of the Solr core where the document will belongpackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the workflow or service is invokeddataModel- the data model to index- Returns:
- the response of the Solr server to the index operation
- Throws:
SolrServerException- if there is an error on the serverIOException- if there is a communication error within the server- Since:
- 2.8.0
- See Also:
- Updating parts of documents
-
writeToIndex
public static UpdateResponse writeToIndex(String coreName, String packageName, Object bean) throws IOException, SolrServerException
Index a document. This one-liner allows the caller to add a new document or update an existing one, depending on the provided arguments.
To index a new bean, its class's fields must be annotated with
Fieldfor Solr to know which fields to index.To update all the fields of a document in Solr, the new bean must be created with the ID of the existing document. With this, the one-liner will replace the existing document entirely with the new bean's data.
To partially update a Solr document, one must create a
SolrInputDocumentand populate the fields using Solr's mechanism for updating Solr fields. For example, assume the following document exists in the core:{ "id": "230498302", "price": 10, "popularity": 42, "categories": [ "kids" ], "promo_ids": [ "a123x" ], "tags": [ "free_to_try", "buy_now", "clearance", "on_sale" ] }In order to update only thepricefield, the caller should pass the followingSolrInputDocumentto this one-liner:SolrInputDocument document = new SolrInputDocument(); document.setField( "id", "230498302" ) Map
modifier = new HashMap<>(); modifier.put( "set", 500 ); document.setField( "price", modifier ); - Parameters:
coreName- the name of the Solr core where the document will belongpackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedbean- the bean to index- Returns:
- the response of the Solr server to the index operation
- Throws:
IOException- if there is a communication error within the serverSolrServerException- if there is an error on the server- Since:
- 1.0
- See Also:
- Updating parts of documents
-
writeToIndex
@Deprecated(since="2.8.0") @GloopObjectParameter("output{\nupdateResponse#io.toro.martini.solr.UpdateResponse{\n }\n}") public static GloopModel writeToIndex(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowNull=false) GloopModel gloopModel) throws IOException, SolrServerException
Deprecated.Index a document. This one-liner allows the caller to add a new document or update an existing one, depending on the provided arguments.
Solr will rely on the Solr core's configured schema to identify which properties of the model to index.
When updating a document, updates are partial. Only provided fields will be indexed. This one-liner also works with Gloop models with
FieldModifierproperties.FieldModifierproperties mirror Solr's modifier argument forSolrInputDocuments.- Parameters:
coreName- the name of the Solr core where the document will belongpackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedgloopModel- the model to index- Returns:
- the response of the Solr server to the index operation
- Throws:
IOException- if there is a communication error within the serverSolrServerException- if there is an error on the server- Since:
- 1.0
- See Also:
- Updating parts of documents
-
commit
public static void commit(@GloopParameter(allowNull=false) String coreName, String packageName) throws IOException, SolrServerException
Explicitly commits all pending documents to the specified Solr core. Use this after direct index operations to make documents visible to queries without relying on the cursor's automatic commit mode.- Parameters:
coreName- the name of the Solr core to commitpackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the workflow or service is invoked- Throws:
IOExceptionSolrServerException
-
query
public static QueryResponse query(String coreName, String packageName, Map<String,String> solrParams)
Query a Solr core.- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedsolrParams- Solr query parameters- Returns:
- the response of the Solr server to the query
- Since:
- 1.0
-
query
@GloopObjectParameter("output{\nqueryResponse#io.toro.martini.solr.QueryResponse{\n }\n}") public static GloopModel query(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowExtraProperties=false) @GloopObjectParameter("solrParams[]{\n paramKey\n paramValue\n}") List<GloopModel> solrParams)
Query a Solr core.- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedsolrParams- Solr query parameters- Returns:
- the response of the Solr server to the query
- Since:
- 1.0
-
queryByMultiMap
public static QueryResponse queryByMultiMap(String coreName, String packageName, Map<String,String[]> solrParams)
Query a Solr core.- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedsolrParams- Solr query parameters- Returns:
- the response of the Solr server to the query
- Since:
- 1.0
-
fieldValueFacetSearch
@GloopObjectParameter("output{\nfieldValueFacet#io.toro.martini.solr.Facet{\n }\n}") public static GloopModel fieldValueFacetSearch(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowNull=false) String fieldName, @GloopParameter(allowExtraProperties=false) @GloopObjectParameter("solrParams[]{\n paramKey\n paramValue\n}") List<GloopModel> solrParams)
Perform a faceted search for a specific field.
Results include the unique values found for the specified field, and the total number of documents where each value is found.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedsolrParams- Solr query parametersfieldName- the name of the field that should be treated as a facet- Returns:
- field-value faceting results
- Since:
- 1.1
- See Also:
- Faceting
-
fieldValueFacetSearch
public static io.toro.martini.solr.Facet fieldValueFacetSearch(String coreName, String packageName, String fieldName, Map<String,Collection<String>> solrParams)
Perform a faceted search for a specific field.
Results include the unique values found for the specified field, and the total number of documents where each value is found.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedsolrParams- Solr query parametersfieldName- the name of the field that should be treated as a facet- Returns:
- field-value faceting results
- Since:
- 1.1
- See Also:
- Faceting
-
multiFieldValueFacetSearch
public static List<io.toro.martini.solr.Facet> multiFieldValueFacetSearch(String coreName, String packageName, Map<String,Collection<String>> solrParams)
Perform a faceted search for a specific set of fields.
Results include the unique values found for each field, and the total number of documents where each value is found.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedsolrParams- Solr query parameters; should have at least onefacet.fieldparameter- Returns:
- field-value faceting results
- Since:
- 1.1
- See Also:
- Faceting
-
multiFieldValueFacetSearch
@GloopObjectParameter("output{\nfieldValueFacet#io.toro.martini.solr.Facet[]{\n }\n}") public static GloopModel multiFieldValueFacetSearch(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowExtraProperties=false) @GloopObjectParameter("solrParams[]{\n paramKey\n paramValue\n}") List<GloopModel> solrParams)
Perform a faceted search for a specific set of fields.
Results include the unique values found for each field, and the total number of documents where each value is found.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedsolrParams- Solr query parameters; should have at least onefacet.fieldparameter- Returns:
- field-value faceting results
- Since:
- 1.1
- See Also:
- Faceting
-
rangeFacetSearch
public static <B,G> io.toro.martini.solr.RangeFacet<B,G> rangeFacetSearch(String coreName, String packageName, String fieldName, Map<String,Collection<String>> solrParams)
Perform a range faceted search for a specific field.
Results include the values found for the field within the specified range, and the total number of documents where each value is found.
- Type Parameters:
B- data type for the lower and upper bound of the rangesG- data type for gap- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedfieldName- the name of the field that should be treated as a facetsolrParams- Solr query parameters- Returns:
- range faceting results
- Since:
- 1.1
-
rangeFacetSearch
@GloopObjectParameter("output{\nrangeFacet#io.toro.martini.solr.FacetRange{\n }\n}") public static GloopModel rangeFacetSearch(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowNull=false) String fieldName, @GloopParameter(allowExtraProperties=false) @GloopObjectParameter("solrParams[]{\n paramKey\n paramValue\n}") List<GloopModel> solrParams)
Perform a range faceted search for a specific field.
Results include the values found for the field within the specified range, and the total number of documents where each value is found.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedfieldName- the name of the field that should be treated as a facetsolrParams- Solr query parameters- Returns:
- range faceting results
- Since:
- 1.1
-
pivotFacetSearch
public static io.toro.martini.solr.PivotFacet pivotFacetSearch(String coreName, String packageName, String fieldName, Map<String,Collection<String>> solrParams)
Perform a pivot faceted search for a specific field.
Results include the values found for each pivot field, and the total number of documents where each value is found.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedfieldName- the name of the field that should be treated as a facetsolrParams- Solr query parameters- Returns:
- pivot faceting results
- Since:
- 1.1
-
pivotFacetSearch
@GloopObjectParameter("output{\npivotFacet#io.toro.martini.solr.PivotField{\n }\n}") public static GloopModel pivotFacetSearch(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowNull=false) String fieldName, @GloopParameter(allowExtraProperties=false) @GloopObjectParameter("solrParams[]{\n paramKey\n paramValue\n}") List<GloopModel> solrParams)
Perform a pivot faceted search for a specific field.
Results include the values found for each pivot field, and the total number of documents where each value is found.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedfieldName- the name of the field that should be treated as a facetsolrParams- Solr query parameters- Returns:
- pivot faceting results
- Since:
- 1.1
-
multiPivotFacetSearch
public static List<io.toro.martini.solr.PivotFacet> multiPivotFacetSearch(String coreName, String packageName, Map<String,Collection<String>> solrParams)
Perform a multi pivot faceted search.
Results include the values found for each pivot field, and the total number of documents where each value is found.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedsolrParams- Solr query parameters; should have at least onefacet.pivotparameter- Returns:
- pivot faceting results
- Since:
- 1.1
-
multiPivotFacetSearch
@GloopObjectParameter("output{\npivotFacet#io.toro.martini.solr.PivotField[]{\n }\n}") public static GloopModel multiPivotFacetSearch(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowExtraProperties=false) @GloopObjectParameter("solrParams[]{\n paramKey\n paramValue\n}") List<GloopModel> solrParams)
Perform a multi pivot faceted search.
Results include the values found for each pivot field, and the total number of documents where each value is found.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedsolrParams- Solr query parameters; should have at least onefacet.pivotparameter- Returns:
- pivot faceting results
- Since:
- 1.1
-
fieldStatisticsSearch
public static io.toro.martini.solr.Stats fieldStatisticsSearch(String coreName, String packageName, String fieldName, Map<String,Collection<String>> solrParams)
Generate statistics for a certain field.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedfieldName- the field for which statistics should be generatedsolrParams- Solr query parameters- Returns:
- statistics for the specified field
- Since:
- 1.1
-
fieldStatisticsSearch
@GloopObjectParameter("output{\nstats#io.toro.martini.solr.FieldStatsInfo{\n }\n}") public static GloopModel fieldStatisticsSearch(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowNull=false) String fieldName, @GloopParameter(allowExtraProperties=false) @GloopObjectParameter("solrParams[]{\n paramKey\n paramValue\n}") List<GloopModel> solrParams)
Generate statistics for a certain field.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedfieldName- the field for which statistics should be generatedsolrParams- Solr query parameters- Returns:
- statistics for the specified field
- Since:
- 1.1
-
multiFieldStatisticsSearch
public static List<io.toro.martini.solr.Stats> multiFieldStatisticsSearch(String coreName, String packageName, Map<String,Collection<String>> solrParams)
Generate statistics for one or more fields.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedsolrParams- Solr query parameters- Returns:
- statistics for the specified field
- Since:
- 1.1
-
multiFieldStatisticsSearch
@GloopObjectParameter("output{\nstats#io.toro.martini.solr.FieldStatsInfo[]{\n }\n}") public static GloopModel multiFieldStatisticsSearch(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowExtraProperties=false) @GloopObjectParameter("solrParams[]{\n paramKey\n paramValue\n}") List<GloopModel> solrParams)
Generate statistics for one or more fields.
- Parameters:
coreName- the name of the Solr core which will receive the querypackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedsolrParams- Solr query parameters- Returns:
- statistics for the specified field
- Since:
- 1.1
-
searchCore
@GloopObjectParameter("output{\nqueryResponse#io.toro.martini.solr.QueryResponse{\n }\n}") public static GloopModel searchCore(@GloopParameter(defaultValue="*:*") String query, @GloopParameter(allowNull=false) String coreName, String packageName, String sortField, @GloopParameter(choices={"Ascending","Descending"},defaultValue="Ascending") String sortType, List<String> fields, @GloopParameter(defaultValue="10") int pageSize, @GloopParameter(defaultValue="1") int page)
Search a Solr core.- Parameters:
query- the search query; default is *:*coreName- the name of the Solr core which will receive the query; if empty, this will assume that all records are being queriedpackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedsortField- the field which the sorting will be based onsortType- the order in which the results are given; default is Ascendingfields- the list of fields to include in the response if empty, this will include all fieldspageSize- the number of results to display in a page; default is 10page- the page number of results to display; default is 1- Returns:
- the response of the Solr server to the query
- Since:
- 1.1
-
solr
public static io.toro.martini.solr.MartiniSolrClient solr(String coreName) throws ToroException
Get the
SolrClientof a named Solr core, belonging to the package in the current context.Example usage:
def solr = 'media_store'.solr() def query = new SolrQuery( 'q=video&sort=price desc' ) def queryResult = solr.query( query )
- Parameters:
coreName- the name of the Solr core- Returns:
- the Solr core's
SolrClient - Throws:
ToroException- Since:
- 1.0
-
solr
public static io.toro.martini.solr.MartiniSolrClient solr(String coreName, GloopExecutionContext context) throws ToroException
Get the
SolrClientof a named Solr core, belonging to the package in the current context.Example usage:
def solr = 'media_store'.solr() def query = new SolrQuery( 'q=video&sort=price desc' ) def queryResult = solr.query( query )
- Parameters:
coreName- the name of the Solr core- Returns:
- the Solr core's
SolrClient - Throws:
ToroException- Since:
- 1.0
-
openDocumentOutputCursor
@GloopObjectParameter("outputCursor{\n outputCursor[]*{\n }\n }") public static GloopCursor openDocumentOutputCursor(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(defaultValue="On Close",choices={"Never","Batch","On Close"}) String commitMode, @GloopParameter(defaultValue="false") boolean closeClient, @GloopParameter(defaultValue="1000") int batchSize, GloopExecutionContext context)
Opens a cursor for streaming Solr document output, document by document, without accumulating the full documents in memory. Use this instead of the other functions when writing a large number of documents.
The cursor can be used in as output array of a repeat node of a workflow or an iterate step of a service. The cursor is automatically closed at the end of the execution.
- Parameters:
coreName- the name of the Solr core where the document will belongpackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the workflow or service is invokedcommitMode- tells the cursor when to commit the cached documents; default is On Close. Possible values are:- Never - do not commit any documents to Solr
- Batch - only commit the documents when the specified batch size is satisfied
- On Close - commit documents only when the cursor is closed
closeClient- boolean value indicating whether the cursor will close the client after it has been exhausted; default isfalsebatchSize- how many written models to cache before sending them to Solr; default is 1000context- the Gloop execution context (automatically mapped by Gloop)- Returns:
- an output cursor that can be used to append data models to
- Since:
- 2.8.0
-
insertMany
@Deprecated(since="2.8.0") public static GloopCursor insertMany(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowNull=false,defaultValue="On Close",choices={"Never","Batch","On Close"}) String commitMode, @GloopParameter(allowNull=false,defaultValue="false") boolean closeClient, GloopExecutionContext context)
Deprecated.Open a Gloop cursor that accepts Gloop models. These Gloop models are converted to aSolrInputDocument, allowing Gloop to write models to Solr.- Parameters:
coreName- the name of the Solr core where the document will belongpackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedcommitMode- tells the cursor when to commit the cached documents; possible values are:- Never - do not commit any documents to Solr
- Batch - only commit the documents when the specified batch size is satisfied
- On Close - commit documents only when the cursor is closed
closeClient- boolean value indicating whether or not the cursor will close the client after it has been exhaustedcontext- the Gloop execution context (automatically mapped by Gloop)- Returns:
- a cursor capable of accepting models that will be written over to Solr
-
insertMany
@Deprecated(since="2.8.0") public static GloopCursor insertMany(@GloopParameter(allowNull=false) String coreName, String packageName, @GloopParameter(allowNull=false,defaultValue="On Close",choices={"Never","Batch","On Close"}) String commitMode, @GloopParameter(allowNull=false,defaultValue="false") boolean closeClient, @GloopParameter(allowNull=false,defaultValue="1000") int batchSize, GloopExecutionContext context)
Deprecated.Open a Gloop cursor that accepts Gloop models. These Gloop models are converted to aSolrInputDocument, allowing Gloop to write models to Solr.- Parameters:
coreName- the name of the Solr core where the document will belongpackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the service is invokedcommitMode- tells the cursor when to commit the cached documents; possible values are:- Never - do not commit any documents to Solr
- Batch - only commit the documents when the specified batch size is satisfied
- On Close - commit documents only when the cursor is closed
closeClient- boolean value indicating whether or not the cursor will close the client after it has been exhaustedbatchSize- how many written models to cache before sending them to Solrcontext- the Gloop execution context (automatically mapped by Gloop)- Returns:
- a cursor capable of accepting models that will be written over to Solr
-
reloadCore
public static void reloadCore(@GloopParameter(allowNull=false) String coreName, String packageName) throws SolrServerException, IOException
Reloads the specified Solr core, applying any configuration changes made since it was last loaded. This does not require restarting Martini.- Parameters:
coreName- the name of the Solr core to reloadpackageName- the name of the package where the Solr core resides; if empty, this will assume the name of the package where the workflow or service is invoked- Throws:
SolrServerExceptionIOException
-
-