You are currently browsing the tag archive for the ‘Solr’ tag.
We now keep track of our solr replication delay, maybe you should too
Works with scout-app or sheriff(free/self-hosted)
class SolrReplication < Scout::Plugin
needs 'open-uri'
OPTIONS=<<-EOS
master:
default: http://192.168.2.114:8983
slave:
default: http://localhost:8765
EOS
def build_report
replication_path = '/solr/admin/replication/index.jsp'
rex = /Generation: (\d+)/
master = open(option(:master)+replication_path).read.match(rex)[1]
slave = open(option(:slave)+replication_path).read.match(rex)[1]
if master and slave
report 'delay' => master.to_i - slave.to_i
else
error "Incorrect values found master:#{master} slave:#{slave}"
end
end
end
We recently did some negative queries and had a lot of ‘fun’ with solr.
After reading/testing a bit we found a simple rule: negative queries for single words do not work (dont ask me why…), but it can be fixed with an additional *:*
Does not work: title: -xxx / (-title:xxx)
When you are only interested in certain fields, query building gets rather conplex:
- contains foo and bar -> title:(foo bar) OR description:(foo bar)
- contains foo or bar -> title:(foo OR bar) OR description:(foo OR bar)
- does not contain foo or bar-> -title:(foo bar *:*) AND -description(foo bar *:*)
The *:* is killed by acts_as_solr, so the parser needs a little fix too:
# lib/parser_methods.rb:80
# *:xxx -> *:xxx a : b -> a_t:b
query = "(#{query.gsub(/([^\*]) *: */, "\\1_t:")}) #{models}"
(see our branch on github)
Hope this helps someone!
Just found out that 37 is an illegal solr character…
x.gsub(“37″,”) solves the problem…
Patch
