diff --git a/client/ruby/solr-ruby/lib/solr/connection.rb b/client/ruby/solr-ruby/lib/solr/connection.rb index 43c906e6a6b..963d1362737 100755 --- a/client/ruby/solr-ruby/lib/solr/connection.rb +++ b/client/ruby/solr-ruby/lib/solr/connection.rb @@ -140,7 +140,7 @@ class Solr::Connection def post(request) response = @connection.post(@url.path + "/" + request.handler, request.to_s, - { "Content-Type" => "application/x-www-form-urlencoded; charset=utf-8" }) + { "Content-Type" => request.content_type }) case response when Net::HTTPSuccess then response.body diff --git a/client/ruby/solr-ruby/lib/solr/importer.rb b/client/ruby/solr-ruby/lib/solr/importer.rb index 0679dccc55b..d607b2c39c3 100755 --- a/client/ruby/solr-ruby/lib/solr/importer.rb +++ b/client/ruby/solr-ruby/lib/solr/importer.rb @@ -12,6 +12,8 @@ module Solr; module Importer; end; end require 'solr/importer/mapper' +require 'solr/importer/array_mapper' require 'solr/importer/delimited_file_source' +require 'solr/importer/hpricot_mapper' require 'solr/importer/xpath_mapper' require 'solr/importer/solr_source' \ No newline at end of file diff --git a/client/ruby/solr-ruby/lib/solr/importer/hpricot_mapper.rb b/client/ruby/solr-ruby/lib/solr/importer/hpricot_mapper.rb new file mode 100644 index 00000000000..f3fe3e0368d --- /dev/null +++ b/client/ruby/solr-ruby/lib/solr/importer/hpricot_mapper.rb @@ -0,0 +1,20 @@ +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'hpricot' + +# For files with the first line containing field names +class Solr::Importer::HpricotMapper < Solr::Importer::Mapper + def field_data(doc, path) + doc.search(path.to_s).collect { |e| e.inner_html } + end +end diff --git a/client/ruby/solr-ruby/lib/solr/indexer.rb b/client/ruby/solr-ruby/lib/solr/indexer.rb index 82f3aaca5cc..b33dec0f25b 100755 --- a/client/ruby/solr-ruby/lib/solr/indexer.rb +++ b/client/ruby/solr-ruby/lib/solr/indexer.rb @@ -13,7 +13,7 @@ class Solr::Indexer # deprecated, use Indexer.new(ds,mapping).index instead def self.index(data_source, mapper_or_mapping, options={}) - indexer = Solr::Indexer.new(data_source, mapper_or_mapping, options={}) + indexer = Solr::Indexer.new(data_source, mapper_or_mapping, options) indexer.index end @@ -33,7 +33,7 @@ class Solr::Indexer @data_source.each do |record| document = @mapper.map(record) - yield(record, document) if block_given? + yield(record, document) if block_given? # TODO check return of block, if not true then don't index buffer << document diff --git a/client/ruby/solr-ruby/lib/solr/request/base.rb b/client/ruby/solr-ruby/lib/solr/request/base.rb index 9b010e6c6d8..9ce8d0cfc79 100644 --- a/client/ruby/solr-ruby/lib/solr/request/base.rb +++ b/client/ruby/solr-ruby/lib/solr/request/base.rb @@ -21,6 +21,10 @@ class Solr::Request::Base def response_format raise "unknown request type: #{self.class}" end + + def content_type + 'text/xml; charset=utf-8' + end # returns the solr handler or url fragment that can # respond to this type of request diff --git a/client/ruby/solr-ruby/lib/solr/request/index_info.rb b/client/ruby/solr-ruby/lib/solr/request/index_info.rb index 4e736c7cf99..f3e7795955a 100755 --- a/client/ruby/solr-ruby/lib/solr/request/index_info.rb +++ b/client/ruby/solr-ruby/lib/solr/request/index_info.rb @@ -11,7 +11,9 @@ # limitations under the License. class Solr::Request::IndexInfo < Solr::Request::Select - def initialize - super('indexinfo') + + def handler + 'admin/luke' end + end diff --git a/client/ruby/solr-ruby/lib/solr/request/select.rb b/client/ruby/solr-ruby/lib/solr/request/select.rb index b594a52a03a..6e04deb4b45 100644 --- a/client/ruby/solr-ruby/lib/solr/request/select.rb +++ b/client/ruby/solr-ruby/lib/solr/request/select.rb @@ -31,6 +31,10 @@ class Solr::Request::Select < Solr::Request::Base def handler 'select' end + + def content_type + 'application/x-www-form-urlencoded; charset=utf-8' + end def to_hash return {:qt => query_type, :wt => 'ruby'} diff --git a/client/ruby/solr-ruby/lib/solr/response/commit.rb b/client/ruby/solr-ruby/lib/solr/response/commit.rb index 13f52681768..ff937a36ac3 100644 --- a/client/ruby/solr-ruby/lib/solr/response/commit.rb +++ b/client/ruby/solr-ruby/lib/solr/response/commit.rb @@ -13,20 +13,5 @@ require 'rexml/xpath' class Solr::Response::Commit < Solr::Response::Xml - attr_reader :ok - - def initialize(xml) - super(xml) - e = REXML::XPath.first(@doc, './result') - if e and e.attributes['status'] == '0' - @ok = true - else - @ok = false - end - end - - def ok? - @ok - end end diff --git a/client/ruby/solr-ruby/lib/solr/response/xml.rb b/client/ruby/solr-ruby/lib/solr/response/xml.rb index df404bcfc12..3e1cc2c81b4 100644 --- a/client/ruby/solr-ruby/lib/solr/response/xml.rb +++ b/client/ruby/solr-ruby/lib/solr/response/xml.rb @@ -20,11 +20,16 @@ class Solr::Response::Xml < Solr::Response::Base super(xml) # parse the xml @doc = REXML::Document.new(xml) + # look for the result code and string - result = REXML::XPath.first(@doc, './result') + # + # + # 02 + # + result = REXML::XPath.first(@doc, './response/lst[@name="responseHeader"]/int[@name="status"]') if result - @status_code = result.attributes['status'] - @status_message = result.text + @status_code = result.text + @status_message = result.text # TODO: any need for a message? end rescue REXML::ParseException => e raise Solr::Exception.new("invalid response xml: #{e}") diff --git a/client/ruby/solr-ruby/solr/conf/solrconfig.xml b/client/ruby/solr-ruby/solr/conf/solrconfig.xml index 4a2299ab50d..ef0afbe2ad4 100755 --- a/client/ruby/solr-ruby/solr/conf/solrconfig.xml +++ b/client/ruby/solr-ruby/solr/conf/solrconfig.xml @@ -17,11 +17,21 @@ --> + + ${solr.abortOnConfigurationError:true} - ${solr.data.dir:./solr/data} + @@ -60,6 +70,7 @@ @@ -114,9 +125,9 @@ --> + size="512" + initialSize="512" + autowarmCount="256"/> false + + 4 + - + + + + + + + - - - - - - @@ -239,7 +259,7 @@ --> - + - - + + + explicit + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 + 2<-1 5<-2 6<90% + + incubationdate_dt:[* TO NOW/DAY-1MONTH]^2.2 + + + + inStock:true + + + + cat + manu_exact + price:[* TO 500] + price:[500 TO *] + + + + + + + inStock:true + + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + + + 2<-1 5<-2 6<90% + - - - - + + + + + 1 + 0.5 + + + + + + + + spell + + + + + word + + + + + + - + + + + + + + + + + + + + + explicit + true + - - q=solr + qt=dismax&q=solr&start=3&fq=id:[* TO *]&fq=cat:[* TO *] + + ${solr.abortOnConfigurationError:true} @@ -215,16 +224,30 @@ warming. --> false + + 4 + - + + + + + + + - @@ -236,7 +259,7 @@ --> - + + + + + + - id, text + id,test 2<-1 5<-2 6<90% - 100 --> + 100 + *:* + + + + + + + 1 + 0.5 + + + + + + + + spell + + + + + word + + + + + + + + + + + + + + + + + + + + + + explicit + true + + + - q=solr + qt=dismax&q=solr&start=3&fq=id:[* TO *]&fq=cat:[* TO *]