com.lucidworks.spark.example.ml

NewsgroupsIndexer

class NewsgroupsIndexer extends RDDProcessor with Logging

Example application to index each article in the 20 newsgroups data as a Solr document. The 20 newsgroups data is downloadable from http://qwone.com/~jason/20Newsgroups/.

Articles in any of the three archives available there can be indexed, after first downloading it from the above page and unpacking it.

The path you supply as an argument to the --path cmdline option (see the "Example invocation" section below) should be the directory containing the newsgroup folders. All files found recursively under this path will be indexed to Solr.

Prerequisites

Start Solr in cloud mode, and create a target collection, e.g. (after downloading the binary Solr distribution - see https://lucene.apache.org/solr/ - then unpacking and changing to the unpacked root directory, e.g. solr-5.4.1/):

bin/solr -c && bin/solr create -c testing -shards 2

Document fields

Each header present in the newsgroup articles will be indexed to a Solr dynamic field name prefixed with the header name, e.g. Subject: text will be indexed into a field named Subject_txt_en.

Note that the set of headers in each of the three available archives is different; details are on the download page above.

The body of each article will be indexed into the content_txt_en field.

The newsgroup_s field will contain the name of the article's parent directory.

The id field value will be in the format newsgroup_articlenum, e.g. "comp.graphics_38659", where newsgroup is the name of the article's parent directory, and articlenum is the article filename.

The filepath_s field will contain the full path of the article source file.

If you downloaded the 20news-19997.tar.gz archive, the only one with the Date: header, dates will be indexed into two fields: the Date_s field will contain the original Date: text, and the Date_tdt field will contain the date reformatted in ISO-8601 format.

Example invocation

You must first run mvn -DskipTests package in the spark-solr project, and you must download a Spark 1.6.1 binary distribution and point the environment variable $SPARK_HOME to the unpacked distribution directory.

$SPARK_HOME/bin/spark-submit --master 'local[2]' --class com.lucidworks.spark.SparkApp \
target/spark-solr-2.0.0-SNAPSHOT-shaded.jar newsgroups2solr -zkHost localhost:9983     \
-collection ml20news -path /relative/or/absolute/path/to/20news-18828`

To see a description of all available options, run the following:

$SPARK_HOME/bin/spark-submit --class com.lucidworks.spark.SparkApp \
target/spark-solr-2.0.0-SNAPSHOT-shaded.jar newsgroups2solr --help
Linear Supertypes
Logging, RDDProcessor, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. NewsgroupsIndexer
  2. Logging
  3. RDDProcessor
  4. Serializable
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new NewsgroupsIndexer()

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  12. def getName(): String

    Definition Classes
    NewsgroupsIndexer → RDDProcessor
  13. def getOptions(): Array[Option]

    Definition Classes
    NewsgroupsIndexer → RDDProcessor
  14. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  16. def isTraceEnabled(): Boolean

    Attributes
    protected
    Definition Classes
    Logging
  17. def loadNewsgroupArticle(stream: PortableDataStream): SolrInputDocument

  18. def log: Logger

    Attributes
    protected
    Definition Classes
    Logging
  19. def logDebug(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  20. def logDebug(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  21. def logError(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  22. def logError(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  23. def logInfo(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  24. def logInfo(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  25. def logName: String

    Attributes
    protected
    Definition Classes
    Logging
  26. def logTrace(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  27. def logTrace(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  28. def logWarning(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  29. def logWarning(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  30. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  31. final def notify(): Unit

    Definition Classes
    AnyRef
  32. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  33. def parseFilePath(basePath: String, filePath: String): (Option[String], String)

  34. def run(conf: SparkConf, cli: CommandLine): Int

    Definition Classes
    NewsgroupsIndexer → RDDProcessor
  35. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  36. def toString(): String

    Definition Classes
    AnyRef → Any
  37. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Logging

Inherited from RDDProcessor

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped