class SolrClient extends AnyRef
This is the simple Apache Solr client for Scala.
- Alphabetic
- By Inheritance
- SolrClient
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new SolrClient(url: String)(implicit factory: (String) => org.apache.solr.client.solrj.SolrClient = (url: String) => new ApacheHttpSolrClient.Builder(url).build(), parser: ExpressionParser = new DefaultExpressionParser())
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def add(docs: Any*): BatchRegister
Execute batch updating.
Execute batch updating.
Note --- VERY IMPORTANT ---: You MUST supply a collection when instantiating the client or you will see an NPE
Note: To register documents actual, you have to call commit after added them.
import jp.sf.amateras.solr.scala._ val client = new SolrClient("http://localhost:8983/solr/collection") <-- collection included in URI client.add(Map("id"->"001", "manu" -> "Lenovo", "name" -> "ThinkPad X201s")) .add(Map("id"->"002", "manu" -> "Lenovo", "name" -> "ThinkPad X202")) .add(Map("id"->"003", "manu" -> "Lenovo", "name" -> "ThinkPad X100e")) .commit
- def addToCollection(collection: String, docs: Any*): BatchRegister
Execute batch updating on the specified collection.
Execute batch updating on the specified collection.
Note: To register documents actual, you have to call commit after added them.
import jp.sf.amateras.solr.scala._ val client = new SolrClient("http://localhost:8983/solr") <-- No collection at end of URI client.addToCollection("collection", Map("id"->"001", "manu" -> "Lenovo", "name" -> "ThinkPad X201s")) .add(Map("id"->"002", "manu" -> "Lenovo", "name" -> "ThinkPad X202")) .add(Map("id"->"003", "manu" -> "Lenovo", "name" -> "ThinkPad X100e")) .commit
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def commit(): UpdateResponse
Commit the current session.
- def commit(collection: String): UpdateResponse
Commit the current session on a specified collection
- def deleteById(collection: String, id: String): UpdateResponse
Delete the document which has a given id in the specified collection.
Delete the document which has a given id in the specified collection.
- collection
the name of the collection
- id
the identifier of the document to delete
- def deleteById(id: String): UpdateResponse
Delete the document which has a given id.
Delete the document which has a given id. See note about client instantiation in
add
documentation- id
the identifier of the document to delete
- def deleteByQuery(query: String, params: Map[String, Any] = Map()): UpdateResponse
Delete documents by the given query.
Delete documents by the given query. See note about client instantiation in
add
documentation- query
the solr query to select documents which would be deleted
- params
the parameter map which would be given to the query
- def deleteByQueryForCollection(collection: String, query: String, params: Map[String, Any] = Map()): UpdateResponse
Delete documents by the given query on the specified collection.
Delete documents by the given query on the specified collection.
- collection
the name of the collection
- query
the solr query to select documents which would be deleted
- params
the parameter map which would be given to the query
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def ping: SolrPingResponse
Check the status of the server You HAVE TO instantiate the client with a collection b/c /solr/admin/ping does not exist.
Check the status of the server You HAVE TO instantiate the client with a collection b/c /solr/admin/ping does not exist.
val client = new SolrClient("http://localhost:8983/solr/collection") val result: SolrPingResponse = client.ping
- def query(query: String): QueryBuilder
Search documents using the given query, note the difference in instantiation as well as use of method collection
Search documents using the given query, note the difference in instantiation as well as use of method collection
import jp.sf.amateras.solr.scala._ val client = new SolrClient("http://localhost:8983/solr") val result: List[Map[String, Any]] = client.query("*:*") .collection("collection") <-- Required or you'll be searching /solr/select .fields("id", "manu", "name") .sortBy("id", Order.asc) .getResultAsMap() --- OR --- val client = new SolrClient("http://localhost:8983/solr/collection") val result: List[Map[String, Any]] = client.query("*:*") .fields("id", "manu", "name") .sortBy("id", Order.asc) .getResultAsMap()
- def register(docs: Any*): UpdateResponse
Add documents and commit them immediately.
Add documents and commit them immediately. See note about client instantiation in
add
documentation- docs
documents to register
- def registerToCollection(collection: String, docs: Any*): UpdateResponse
Add documents and commit them immediately to the specified collection.
Add documents and commit them immediately to the specified collection.
- collection
the name of the collection
- docs
documents to register
- def rollback(): UpdateResponse
Rolled back the current session.
- def rollback(collection: String): UpdateResponse
Rolled back the current session on a collection
- def shutdown(): Unit
Shutdown this solr client to release allocated resources.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def withTransaction[T](operations: => T): T
Execute given operation in the transaction.
Execute given operation in the transaction.
The transaction is committed if operation was successful. But the transaction is rolled back if an error occurred.
- def withTransactionOnCollection[T](collection: String)(operations: => T): T
Execute given operation in the transaction to a collection
Execute given operation in the transaction to a collection
The transaction is committed if operation was successful. But the transaction is rolled back if an error occurred.