outoftime-sunspot 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/History.txt +9 -6
  2. data/README.rdoc +45 -13
  3. data/Rakefile +5 -21
  4. data/VERSION.yml +4 -0
  5. data/bin/sunspot-solr +39 -0
  6. data/lib/sunspot/builder.rb +78 -0
  7. data/lib/sunspot/dsl/fields.rb +39 -0
  8. data/lib/sunspot/dsl/query.rb +32 -0
  9. data/lib/sunspot/dsl/scope.rb +35 -0
  10. data/lib/sunspot/dsl.rb +3 -0
  11. data/lib/sunspot/query.rb +9 -20
  12. data/lib/sunspot/search.rb +8 -25
  13. data/lib/sunspot.rb +2 -3
  14. data/solr/etc/jetty.xml +10 -4
  15. data/solr/solr/conf/{admin-extra.html → elevate.xml} +18 -13
  16. data/solr/solr/conf/solrconfig.xml +369 -67
  17. data/solr/webapps/solr.war +0 -0
  18. data/spec/api/build_search_spec.rb +195 -0
  19. data/spec/api/indexer_spec.rb +112 -0
  20. data/spec/api/search_retrieval_spec.rb +59 -0
  21. data/spec/api/session_spec.rb +44 -0
  22. data/spec/api/spec_helper.rb +1 -0
  23. data/spec/api/standard_search_builder_spec.rb +76 -0
  24. data/{test → spec}/custom_expectation.rb +0 -0
  25. data/{test/integration/test_field_types.rb → spec/integration/field_types_spec.rb} +9 -9
  26. data/{test/integration/test_keyword_search.rb → spec/integration/keyword_search_spec.rb} +5 -5
  27. data/spec/integration/spec_helper.rb +1 -0
  28. data/{test → spec}/integration/test_pagination.rb +5 -5
  29. data/{test → spec}/mocks/base_class.rb +0 -0
  30. data/{test → spec}/mocks/comment.rb +0 -0
  31. data/{test → spec}/mocks/mock_adapter.rb +0 -0
  32. data/{test → spec}/mocks/post.rb +0 -0
  33. data/{test/test_helper.rb → spec/spec_helper.rb} +6 -12
  34. data/tasks/gemspec.rake +18 -0
  35. data/tasks/rcov.rake +27 -5
  36. data/tasks/spec.rake +21 -0
  37. metadata +90 -125
  38. data/Manifest.txt +0 -104
  39. data/PostInstall.txt +0 -7
  40. data/config/hoe.rb +0 -74
  41. data/config/requirements.rb +0 -15
  42. data/lib/sunspot/conditions.rb +0 -50
  43. data/lib/sunspot/conditions_builder.rb +0 -37
  44. data/lib/sunspot/field_builder.rb +0 -37
  45. data/lib/sunspot/query_builder.rb +0 -30
  46. data/lib/sunspot/scope_builder.rb +0 -33
  47. data/lib/sunspot/version.rb +0 -10
  48. data/setup.rb +0 -1585
  49. data/solr/README.txt +0 -36
  50. data/solr/exampledocs/books.csv +0 -11
  51. data/solr/exampledocs/hd.xml +0 -46
  52. data/solr/exampledocs/ipod_other.xml +0 -50
  53. data/solr/exampledocs/ipod_video.xml +0 -35
  54. data/solr/exampledocs/mem.xml +0 -58
  55. data/solr/exampledocs/monitor.xml +0 -31
  56. data/solr/exampledocs/monitor2.xml +0 -30
  57. data/solr/exampledocs/mp500.xml +0 -39
  58. data/solr/exampledocs/post.jar +0 -0
  59. data/solr/exampledocs/post.sh +0 -28
  60. data/solr/exampledocs/sd500.xml +0 -33
  61. data/solr/exampledocs/solr.xml +0 -38
  62. data/solr/exampledocs/spellchecker.xml +0 -58
  63. data/solr/exampledocs/utf8-example.xml +0 -42
  64. data/solr/exampledocs/vidcard.xml +0 -52
  65. data/solr/solr/README.txt +0 -52
  66. data/solr/solr/bin/abc +0 -176
  67. data/solr/solr/bin/abo +0 -176
  68. data/solr/solr/bin/backup +0 -108
  69. data/solr/solr/bin/backupcleaner +0 -142
  70. data/solr/solr/bin/commit +0 -128
  71. data/solr/solr/bin/optimize +0 -129
  72. data/solr/solr/bin/readercycle +0 -129
  73. data/solr/solr/bin/rsyncd-disable +0 -77
  74. data/solr/solr/bin/rsyncd-enable +0 -76
  75. data/solr/solr/bin/rsyncd-start +0 -145
  76. data/solr/solr/bin/rsyncd-stop +0 -105
  77. data/solr/solr/bin/scripts-util +0 -83
  78. data/solr/solr/bin/snapcleaner +0 -148
  79. data/solr/solr/bin/snapinstaller +0 -168
  80. data/solr/solr/bin/snappuller +0 -248
  81. data/solr/solr/bin/snappuller-disable +0 -77
  82. data/solr/solr/bin/snappuller-enable +0 -77
  83. data/solr/solr/bin/snapshooter +0 -109
  84. data/solr/solr/conf/scripts.conf +0 -24
  85. data/tasks/deployment.rake +0 -34
  86. data/tasks/environment.rake +0 -7
  87. data/tasks/solr.rake +0 -12
  88. data/tasks/website.rake +0 -17
  89. data/test/api/test_build_search.rb +0 -216
  90. data/test/api/test_helper.rb +0 -4
  91. data/test/api/test_indexer.rb +0 -110
  92. data/test/api/test_retrieve_search.rb +0 -114
  93. data/test/api/test_session.rb +0 -46
  94. data/test/integration/test_helper.rb +0 -1
@@ -1,105 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Licensed to the Apache Software Foundation (ASF) under one or more
4
- # contributor license agreements. See the NOTICE file distributed with
5
- # this work for additional information regarding copyright ownership.
6
- # The ASF licenses this file to You under the Apache License, Version 2.0
7
- # (the "License"); you may not use this file except in compliance with
8
- # the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
- # Shell script to stop rsyncd on master Solr server
19
-
20
- orig_dir=$(pwd)
21
- cd ${0%/*}/..
22
- solr_root=$(pwd)
23
- cd ${orig_dir}
24
-
25
- unset user verbose debug
26
- . ${solr_root}/bin/scripts-util
27
-
28
- # set up variables
29
- prog=${0##*/}
30
- log=${solr_root}/logs/rsyncd.log
31
-
32
- # define usage string
33
- USAGE="\
34
- usage: $prog [-u username] [-v]
35
- -u specify user to sudo to before running script
36
- -v increase verbosity
37
- -V output debugging info
38
- "
39
-
40
- # parse args
41
- while getopts u:vV OPTION
42
- do
43
- case $OPTION in
44
- u)
45
- user="$OPTARG"
46
- ;;
47
- v)
48
- verbose="v"
49
- ;;
50
- V)
51
- debug="V"
52
- ;;
53
- *)
54
- echo "$USAGE"
55
- exit 1
56
- esac
57
- done
58
-
59
- [[ -n $debug ]] && set -x
60
-
61
- fixUser "$@"
62
-
63
- logMessage stopped by $oldwhoami
64
- logMessage command: $0 $@
65
-
66
- # look for pid file
67
- if [[ ! -f ${solr_root}/logs/rsyncd.pid ]]
68
- then
69
- logMessage "missing rsyncd pid file ${solr_root}/logs/rsyncd.pid"
70
- exit 2
71
- fi
72
-
73
- # get PID from file
74
- pid=$(<${solr_root}/logs/rsyncd.pid)
75
- if [[ -z $pid ]]
76
- then
77
- logMessage "unable to get rsyncd's PID"
78
- exit 2
79
- fi
80
-
81
- kill $pid
82
-
83
- # wait until rsyncd dies or we time out
84
- dead=0
85
- timer=0
86
- timeout=300
87
- while (( ! dead && timer < timeout ))
88
- do
89
- if ps -eo pid | grep -qw $pid
90
- then
91
- kill $pid
92
- (( timer++ ))
93
- sleep 1
94
- else
95
- dead=1
96
- fi
97
- done
98
- if ps -eo pid | grep -qw $pid
99
- then
100
- logMessage rsyncd failed to stop after $timeout seconds
101
- exit 3
102
- fi
103
-
104
- # remove rsyncd.conf
105
- /bin/rm -f ${solr_root}/conf/rsyncd.conf
@@ -1,83 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Licensed to the Apache Software Foundation (ASF) under one or more
4
- # contributor license agreements. See the NOTICE file distributed with
5
- # this work for additional information regarding copyright ownership.
6
- # The ASF licenses this file to You under the Apache License, Version 2.0
7
- # (the "License"); you may not use this file except in compliance with
8
- # the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
- # util functions used by scripts
19
-
20
- export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
21
-
22
- # set up variables
23
- prog=${0##*/}
24
-
25
- # source the config file if present
26
- confFile=${solr_root}/conf/scripts.conf
27
- if [[ -f $confFile ]]
28
- then
29
- . $confFile
30
- fi
31
-
32
- function fixUser
33
- {
34
- # set user to $(whoami) if not specified
35
- if [[ -z ${user} ]]
36
- then
37
- user=$(whoami)
38
- fi
39
-
40
- # sudo
41
- if [[ $(whoami) != ${user} ]]
42
- then
43
- sudo -u ${user} $0 "$@"
44
- exit $?
45
- fi
46
-
47
- oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
48
-
49
- if [[ "${oldwhoami}" == "" ]]
50
- then
51
- oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
52
- fi
53
- }
54
-
55
- function timeStamp
56
- {
57
- date +'%Y/%m/%d %H:%M:%S'
58
- }
59
-
60
- function logMessage
61
- {
62
- echo $(timeStamp) $@>>$log
63
- if [[ -n ${verbose} ]]
64
- then
65
- echo $@
66
- fi
67
- }
68
-
69
- function logExit
70
- {
71
- end=`date +"%s"`
72
- diff=`expr $end - $start`
73
- echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
74
- exit $2
75
- }
76
-
77
- # create logs directory if not there
78
- if [[ ! -d ${solr_root}/logs ]]
79
- then
80
- mkdir ${solr_root}/logs
81
- fi
82
-
83
- umask 002
@@ -1,148 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Licensed to the Apache Software Foundation (ASF) under one or more
4
- # contributor license agreements. See the NOTICE file distributed with
5
- # this work for additional information regarding copyright ownership.
6
- # The ASF licenses this file to You under the Apache License, Version 2.0
7
- # (the "License"); you may not use this file except in compliance with
8
- # the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
- # Shell script to clean up snapshots of a Solr Lucene collection.
19
-
20
- orig_dir=$(pwd)
21
- cd ${0%/*}/..
22
- solr_root=$(pwd)
23
- cd ${orig_dir}
24
-
25
- unset days num data_dir user verbose debug
26
- . ${solr_root}/bin/scripts-util
27
-
28
- # set up variables
29
- prog=${0##*/}
30
- log=${solr_root}/logs/${prog}.log
31
-
32
- # define usage string
33
- USAGE="\
34
- usage: $prog -D <days> | -N <num> [-d dir] [-u username] [-v]
35
- -D <days> cleanup snapshots more than <days> days old
36
- -N <num> keep the most recent <num> number of snapshots and
37
- cleanup up the remaining ones that are not being pulled
38
- -d specify directory holding index data
39
- -u specify user to sudo to before running script
40
- -v increase verbosity
41
- -V output debugging info
42
- "
43
-
44
- # parse args
45
- while getopts D:N:d:u:vV OPTION
46
- do
47
- case $OPTION in
48
- D)
49
- days="$OPTARG"
50
- ;;
51
- N)
52
- num="$OPTARG"
53
- ;;
54
- d)
55
- data_dir="$OPTARG"
56
- ;;
57
- u)
58
- user="$OPTARG"
59
- ;;
60
- v)
61
- verbose="v"
62
- ;;
63
- V)
64
- debug="V"
65
- ;;
66
- *)
67
- echo "$USAGE"
68
- exit 1
69
- esac
70
- done
71
-
72
- [[ -n $debug ]] && set -x
73
-
74
- if [[ -z ${days} && -z ${num} ]]
75
- then
76
- echo "$USAGE"
77
- exit 1
78
- fi
79
-
80
- fixUser "$@"
81
-
82
- # use default value for data_dir if not specified
83
- # relative path starts at ${solr_root}
84
- if [[ -z ${data_dir} ]]
85
- then
86
- data_dir=${solr_root}/data
87
- elif [[ "`echo ${data_dir}|cut -c1`" != "/" ]]
88
- then
89
- data_dir=${solr_root}/${data_dir}
90
- fi
91
-
92
- function remove
93
- {
94
- syncing=`ps -fwwwu ${user}|grep -w rsync|grep -v grep|grep -w $1`
95
- if [[ -n $syncing ]]
96
- then
97
- logMessage $1 not removed - rsync in progress
98
- else
99
- logMessage removing snapshot $1
100
- /bin/rm -rf $1
101
- fi
102
- }
103
-
104
- start=`date +"%s"`
105
-
106
- logMessage started by $oldwhoami
107
- logMessage command: $0 $@
108
-
109
- # trap control-c
110
- trap 'echo "caught INT/TERM, exiting now but partial cleanup may have already occured";logExit aborted 13' INT TERM
111
-
112
- if [[ -n ${days} ]]
113
- then
114
- #is maxdepth supported?
115
- find ${data_dir} -maxdepth 0 -name foobar >/dev/null 2>&1
116
- if [ $? = 0 ]; then
117
- maxdepth="-maxdepth 1"
118
- else
119
- unset maxdepth
120
- fi
121
-
122
- logMessage cleaning up snapshots more than ${days} days old
123
- for i in `find ${data_dir} ${maxdepth} -name 'snapshot.*' -mtime +${days} -print`
124
- do
125
- remove $i
126
- done
127
- elif [[ -n ${num} ]]
128
- then
129
- logMessage cleaning up all snapshots except for the most recent ${num} ones
130
- unset snapshots count
131
- snapshots=`ls -cd ${data_dir}/snapshot.* 2>/dev/null`
132
- if [[ $? == 0 ]]
133
- then
134
- count=`echo $snapshots|wc -w`
135
- startpos=`expr $num + 1`
136
- if [[ $count -gt $num ]]
137
- then
138
- for i in `echo $snapshots|cut -f${startpos}- -d" "`
139
- do
140
- remove $i
141
- done
142
- fi
143
- fi
144
- fi
145
-
146
- logExit ended 0
147
-
148
-
@@ -1,168 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Licensed to the Apache Software Foundation (ASF) under one or more
4
- # contributor license agreements. See the NOTICE file distributed with
5
- # this work for additional information regarding copyright ownership.
6
- # The ASF licenses this file to You under the Apache License, Version 2.0
7
- # (the "License"); you may not use this file except in compliance with
8
- # the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
- # Shell script to install a snapshot into place as the Lucene collection
19
- # for a Solr server
20
-
21
- orig_dir=$(pwd)
22
- cd ${0%/*}/..
23
- solr_root=$(pwd)
24
- cd ${orig_dir}
25
-
26
- unset master_host master_status_dir data_dir user verbose debug
27
- . ${solr_root}/bin/scripts-util
28
-
29
- # set up variables
30
- prog=${0##*/}
31
- log=${solr_root}/logs/${prog}.log
32
-
33
- # define usage string
34
- USAGE="\
35
- usage: $prog [-M master] [-S sdir] [-d dir] [-u username] [-v]
36
- -M master specify hostname of master server from where to pull index
37
- snapshot
38
- -S specify directory holding snapshot status on master server
39
- -d specify directory holding index data on local machine
40
- -u specify user to sudo to before running script
41
- -v increase verbosity
42
- -V output debugging info
43
- "
44
-
45
- # parse args
46
- while getopts M:S:d:u:vV OPTION
47
- do
48
- case $OPTION in
49
- M)
50
- master_host="$OPTARG"
51
- ;;
52
- S)
53
- master_status_dir="$OPTARG"
54
- ;;
55
- d)
56
- data_dir="$OPTARG"
57
- ;;
58
- u)
59
- user="$OPTARG"
60
- ;;
61
- v)
62
- verbose="v"
63
- ;;
64
- V)
65
- debug="V"
66
- ;;
67
- *)
68
- echo "$USAGE"
69
- exit 1
70
- esac
71
- done
72
-
73
- [[ -n $debug ]] && set -x
74
-
75
- if [[ -z ${master_host} ]]
76
- then
77
- echo "name of master server missing in $confFile or command line."
78
- echo "$USAGE"
79
- exit 1
80
- fi
81
-
82
- if [[ -z ${master_status_dir} ]]
83
- then
84
- echo "directory holding snapshot status on master server missing in $confFile or command line."
85
- echo "$USAGE"
86
- exit 1
87
- fi
88
-
89
- fixUser "$@"
90
-
91
- # use default value for data_dir if not specified
92
- # relative path starts at ${solr_root}
93
- if [[ -z ${data_dir} ]]
94
- then
95
- data_dir=${solr_root}/data
96
- elif [[ "`echo ${data_dir}|cut -c1`" != "/" ]]
97
- then
98
- data_dir=${solr_root}/${data_dir}
99
- fi
100
-
101
- # assume relative path to start at ${solr_root}
102
- if [[ "`echo ${master_status_dir}|cut -c1`" != "/" ]]
103
- then
104
- master_status_dir=${solr_root}/${master_status_dir}
105
- fi
106
-
107
- start=`date +"%s"`
108
-
109
- logMessage started by $oldwhoami
110
- logMessage command: $0 $@
111
-
112
- # get directory name of latest snapshot
113
- name=`ls ${data_dir}|grep 'snapshot\.'|grep -v wip|sort -r|head -1`
114
-
115
- # clean up after INT/TERM
116
- trap 'echo "caught INT/TERM, exiting now but partial installation may have already occured";/bin/rm -rf ${data_dir"/index.tmp$$;logExit aborted 13' INT TERM
117
-
118
- # is there a snapshot
119
- if [[ "${name}" == "" ]]
120
- then
121
- logMessage no shapshot available
122
- logExit ended 0
123
- fi
124
-
125
- name=${data_dir}/${name}
126
-
127
- # has snapshot already been installed
128
- if [[ ${name} == `cat ${solr_root}/logs/snapshot.current 2>/dev/null` ]]
129
- then
130
- logMessage latest snapshot ${name} already installed
131
- logExit ended 0
132
- fi
133
-
134
- # make sure master has directory for hold slaves stats/state
135
- if
136
- ! ssh -o StrictHostKeyChecking=no ${master_host} mkdir -p ${master_status_dir}
137
- then
138
- logMessage failed to ssh to master ${master_host}, snapshot status not updated on master
139
- fi
140
-
141
- # install using hard links into temporary directory
142
- # remove original index and then atomically copy new one into place
143
- logMessage installing snapshot ${name}
144
- cp -lr ${name}/ ${data_dir}/index.tmp$$
145
- /bin/rm -rf ${data_dir}/index
146
- mv -f ${data_dir}/index.tmp$$ ${data_dir}/index
147
-
148
- # update distribution stats
149
- echo ${name} > ${solr_root}/logs/snapshot.current
150
-
151
- # push stats/state to master
152
- if
153
- ! scp -q -o StrictHostKeyChecking=no ${solr_root}/logs/snapshot.current ${master_host}:${master_status_dir}/snapshot.current.`uname -n`
154
- then
155
- logMessage failed to ssh to master ${master_host}, snapshot status not updated on master
156
- fi
157
-
158
- # notify Solr to open a new Searcher
159
- logMessage notifing Solr to open a new Searcher
160
- ${solr_root}/bin/commit
161
- if [[ $? != 0 ]]
162
- then
163
- logMessage failed to connect to Solr server
164
- logMessage snapshot installed but Solr server has not open a new Searcher
165
- logExit failed 1
166
- fi
167
-
168
- logExit ended 0