Class: CouchShell::CoreLucenePlugin
- Defined in:
- lib/couch-shell-plugin/core_lucene.rb
Instance Method Summary collapse
Methods inherited from Plugin
inherited, #initialize, #plugin_info, #plugin_name, #shell, #variables_object
Methods included from PluginUtils
#continue?, #dbname!, #editfile!, #edittext!, #ensure_at_database, #request!
Constructor Details
This class inherits a constructor from CouchShell::Plugin
Instance Method Details
#execute_editfti(argstr) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/couch-shell-plugin/core_lucene.rb', line 20 def execute_editfti(argstr) dbname = dbname! design_name, index_name = argstr.split(/\s+/, 2) if argstr if design_name.nil? || index_name.nil? raise ShellError, "design and fulltext index name required" end res = request! "GET", "/#{dbname}/_design/#{design_name}", nil, false design = res.json_value index = design.fulltext[index_name] if design["fulltext"] indexfun = index && index["index"] new_indexfun = edittext!(indexfun || "function(doc) {\n var ret = Document.new();\n\n return ret;\n}\n") @ftitext = new_indexfun if new_indexfun == indexfun shell.msg "Index function hasn't changed. Nothing to submit." return end continue? "Press ENTER to submit #{indexfun ? 'updated' : 'new'} " + "index function, CTRL+C to cancel " if design["fulltext"].nil? design.set_attr!("fulltext", {}) end if index.nil? design.fulltext.set_attr!(index_name, {}) index = design.fulltext[index_name] end index.set_attr!("index", new_indexfun) unless shell.request("PUT", "/#{dbname}/_design/#{design_name}", design.to_s).ok? shell.msg "recover index text with `print ftitext'" end end |
#lookup_ftitext ⇒ Object
14 15 16 |
# File 'lib/couch-shell-plugin/core_lucene.rb', line 14 def lookup_ftitext @ftitext or raise VarNotSet end |
#plugin_initialization ⇒ Object
9 10 11 |
# File 'lib/couch-shell-plugin/core_lucene.rb', line 9 def plugin_initialization @ftitext = nil end |