Class: ITRP::Cmd_query_fts

Inherits:
Cmd
  • Object
show all
Defined in:
lib/handlers/query_fts.rb

Instance Attribute Summary

Attributes inherited from Cmd

#attach_cmd, #children, #enabled_in_state, #trigger

Instance Method Summary collapse

Methods inherited from Cmd

#appstate, #find_node, #is_root?, #place_node, #print_state, #set_time_window, #treeprint

Constructor Details

#initialize(e) ⇒ Cmd_query_fts

Returns a new instance of Cmd_query_fts.



4
5
6
7
8
9
# File 'lib/handlers/query_fts.rb', line 4

def initialize (e)
	super(e)
	@enabled_in_state = :fts
	@attach_cmd  = ''
	@trigger = 'query'
end

Instance Method Details

#completions(patt) ⇒ Object



11
12
13
# File 'lib/handlers/query_fts.rb', line 11

def completions(patt)
	%w( keywords ) 
end

#enter(patt) ⇒ Object



15
16
17
18
19
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
# File 'lib/handlers/query_fts.rb', line 15

def enter(patt)

terms = patt.scan( /keywords\s*=\s*(.+)/ )

		req =mk_request(TRP::Message::Command::QUERY_FTS_REQUEST,
		 { 	:fts_group  => appstate(:cgguid),
                     	:time_interval =>  appstate(:time_interval),
			:maxitems => 20,
			:keywords => terms.flatten.first 
		})


    rows = [] 

		get_response_zmq(@appenv.zmq_endpt,req) do |resp|

        resp.documents.each do | doc |
            rows << [ doc.dockey, 
                      doc.flows.inject("") do |acc,item|
                        item.key  + "( " + item.time.tv_sec.to_s  + ")"
                      end,
		  doc.fullcontent.size
                   ]
        end

    end

		table = Terminal::Table.new( 
:headings => %w(DocID Flows Content),
:rows => rows)
		puts(table) 
end