yeyicheng

Untitled

Apr 28th, 2014
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.33 KB | None | 0 0
  1. export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_51
  2. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3.  
  4. # get crawl_path and solr_url from arguments, set to default values if not given
  5. CRAWL_PATH="$1"
  6. SOLR_URL="$2"
  7. if [ "$CRAWL_PATH" == "" ]; then
  8.   CRAWL_PATH="crawl"
  9. fi
  10. if [ "$SOLR_URL" == "" ]; then
  11.   SOLR_URL="http://localhost:8983/solr"
  12. fi
  13.  
  14. # rename seed.txt to seed_timestamp.txt
  15. timestamp=$(date +"%s")
  16. OLD_DIR=$DIR"/urls1/seed.txt"
  17. SEED_DIR=$DIR"/urls1/seed_"$timestamp".txt"
  18. mv $OLD_DIR $SEED_DIR
  19.  
  20. # re-create the seed.txt if not exist; use this file to accept new records
  21. echo '' >> $OLD_DIR
  22.  
  23. # generate segments from the urls in seed_timestamp.txt
  24. $DIR/bin/nutch freegen $SEED_DIR $DIR/$CRAWL_PATH/segments
  25. # find the generated segments
  26. SEGMENT=`ls $DIR/$CRAWL_PATH/segments/ | sort -n | tail -n 1`
  27.  
  28. # fetch the segment
  29. $DIR/bin/nutch fetch $DIR/$CRAWL_PATH/segments/$SEGMENT
  30.  
  31. # parse the segment
  32. $DIR/bin/nutch parse $DIR/$CRAWL_PATH/segments/$SEGMENT
  33.  
  34. # updatedb with this segment
  35. $DIR/bin/nutch updatedb $DIR/$CRAWL_PATH/crawldb $DIR/$CRAWL_PATH/segments/$SEGMENT
  36.  
  37. # link inversion
  38. $DIR/bin/nutch invertlinks $DIR/$CRAWL_PATH/linkdb $DIR/$CRAWL_PATH/segments/$SEGMENT
  39.  
  40. # index with solr
  41. $DIR/bin/nutch solrindex $SOLR_URL $DIR/$CRAWL_PATH/crawldb -linkdb $DIR/$CRAWL_PATH/linkdb $DIR/$CRAWL_PATH/segments/$SEGMENT
Advertisement
Add Comment
Please, Sign In to add comment