Class/Object

com.lucidworks.spark.example.ml

NewsgroupsIndexer

Related Docs: object NewsgroupsIndexer | package ml

Permalink

class NewsgroupsIndexer extends RDDProcessor with LazyLogging

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
LazyLogging, RDDProcessor, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. NewsgroupsIndexer
  2. LazyLogging
  3. RDDProcessor
  4. Serializable
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new NewsgroupsIndexer()

    Permalink

Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

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

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    Any
  14. def loadNewsgroupArticle(stream: PortableDataStream): SolrInputDocument

    Permalink
  15. lazy val logger: Logger

    Permalink
    Attributes
    protected
    Definition Classes
    LazyLogging
  16. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

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

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

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

    Permalink
    Definition Classes
    AnyRef
  22. def toString(): String

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from LazyLogging

Inherited from RDDProcessor

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped